feat: adjust logging; implement pem crl endpoint; add crl entries metric; lock on UseCrl
This commit is contained in:
@@ -16,19 +16,26 @@ var (
|
||||
}, []string{labelPath})
|
||||
|
||||
responseStatus = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: "response_status",
|
||||
Name: "http_response_status",
|
||||
Help: "Status of HTTP response",
|
||||
}, []string{labelPath, labelStatus})
|
||||
|
||||
httpDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
|
||||
Name: "http_response_time_seconds",
|
||||
Help: "Duration of HTTP requests.",
|
||||
Buckets: prometheus.DefBuckets,
|
||||
Buckets: prometheus.ExponentialBuckets(0.0001, 2, 10),
|
||||
}, []string{labelPath})
|
||||
|
||||
CrlEntries = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Namespace: "ocspcrl",
|
||||
Name: "crl_entries_total",
|
||||
Help: "Number of entries in the CRL",
|
||||
})
|
||||
)
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(totalRequests)
|
||||
prometheus.MustRegister(responseStatus)
|
||||
prometheus.MustRegister(httpDuration)
|
||||
prometheus.MustRegister(CrlEntries)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"crypto/x509"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/crypto/ocsp"
|
||||
@@ -16,6 +17,7 @@ type CrlSource struct {
|
||||
responderCertificate *x509.Certificate
|
||||
responderKey crypto.Signer
|
||||
crl *x509.RevocationList
|
||||
crlMutex sync.Mutex
|
||||
}
|
||||
|
||||
func NewCrlSource(caCertificate *x509.Certificate, responderKeyPair tls.Certificate) *CrlSource {
|
||||
@@ -26,8 +28,10 @@ func NewCrlSource(caCertificate *x509.Certificate, responderKeyPair tls.Certific
|
||||
}
|
||||
}
|
||||
|
||||
func (source *CrlSource) UseCrl(crl *x509.RevocationList) {
|
||||
source.crl = crl
|
||||
func (source *CrlSource) UseCrl(crl x509.RevocationList) {
|
||||
source.crlMutex.Lock()
|
||||
defer source.crlMutex.Unlock()
|
||||
source.crl = &crl
|
||||
}
|
||||
|
||||
func (source *CrlSource) Response(request *ocsp.Request) ([]byte, http.Header, error) {
|
||||
|
||||
Reference in New Issue
Block a user