refactor: Split large main file

This commit is contained in:
T. R. Bernstein
2026-04-30 02:09:16 +02:00
parent 4e4dd2eaae
commit 853e2a909f
7 changed files with 332 additions and 291 deletions

38
ca.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import (
"crypto/x509"
"sync"
"ocspcrl/internal/metrics"
"ocspcrl/internal/ocsp_source"
)
type caInstance struct {
name string
crlPath string
caCertificate *x509.Certificate
source *ocsp_source.CrlSource
crlMutex sync.RWMutex
crl *x509.RevocationList
}
func (c *caInstance) reloadCrl() error {
crl, loadError := loadCrlFromFile(c.crlPath)
if loadError != nil {
return loadError
}
c.crlMutex.Lock()
c.crl = crl
c.crlMutex.Unlock()
metrics.CrlEntries.WithLabelValues(c.name).Set(float64(len(crl.RevokedCertificateEntries)))
c.source.UseCrl(*crl)
return nil
}
func (c *caInstance) currentCrl() *x509.RevocationList {
c.crlMutex.RLock()
defer c.crlMutex.RUnlock()
return c.crl
}