nats-io/nats-server · error
no certificate found
Error message
no certificate found
What it means
NewOCSPMonitor guard: the tls.Certificate entry has no parsed Leaf and an empty Certificate chain, so there is no certificate material to build an OCSP monitor from. Occurs in tests or embedded setups that inject empty certificate slots.
Source
Thrown at server/ocsp.go:399
caFile = opts.TLSCaCert
}
}
if tcOpts != nil {
certFile = tcOpts.CertFile
caFile = tcOpts.CaFile
}
// NOTE: Currently OCSP Stapling is enabled only for the first certificate found.
var mon *OCSPMonitor
for _, currentCert := range tc.Certificates {
// Create local copy since this will be used in the GetCertificate callback.
cert := currentCert
// This is normally non-nil, but can still be nil here when in tests
// or in some embedded scenarios.
if cert.Leaf == nil {
if len(cert.Certificate) <= 0 {
return nil, nil, fmt.Errorf("no certificate found")
}
var err error
cert.Leaf, err = x509.ParseCertificate(cert.Certificate[0])
if err != nil {
return nil, nil, fmt.Errorf("error parsing certificate: %v", err)
}
}
var shutdownOnRevoke bool
mustStaple := hasOCSPStatusRequest(cert.Leaf)
if oc != nil {
switch {
case oc.Mode == OCSPModeNever:
if mustStaple {
srv.Warnf("Certificate at '%s' has MustStaple but OCSP is disabled", certFile)
}
return tc, nil, nil
case oc.Mode == OCSPModeAlways:
// Start the monitor for this cert even if it does not haveView on GitHub (pinned to 3a66a489d2)
Solutions
- Provide a TLS certificate with at least one DER-encoded chain element
- Skip OCSP monitoring for terminations that have no certificate
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at server/ocsp.go:399 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- SSL/TLS and certificate errors — how TLS handshakes and certificate validation fail.
AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02).
Data as JSON: /api/errors/e78a361c5b1d5b63.
Report an issue: GitHub.