Documentation
¶
Overview ¶
Package ocsp is the OCSP revocation-checking engine for upstream TLS certificates: a TTL'd verdict cache plus the responder query pipeline behind a tls.Config VerifyPeerCertificate callback. Extracted from package main per ADR-0002; the transport wiring (ConfigureTLSConfigOCSP / ConfigureTransportOCSP, under the P5.3 upstream-transport ownership contract) and the globalOCSP singleton stay in main (ocsp.go shim).
When enabled, the proxy verifies that upstream server certificates have not been revoked by checking OCSP stapled responses and, as a fallback, querying OCSP responders listed in the certificate's AIA extension.
CHAOS-65 — the input to this engine is chosen by the party being checked ¶
Everything this package acts on comes out of the PEER's certificate: the responder URLs (`leaf.OCSPServer`), how many of them there are, and — because the peer names the responder — the bytes that come back. Four rules follow, and none of them may be relaxed:
- A response is a verdict only when it is BOUND to the certificate under test (ParseResponseForCert, never ParseResponse) and FRESH. Without the binding, a genuine CA-signed "good" about any other certificate of the same issuer answers for this one; without the freshness check, a "good" captured before revocation replays forever, since the request carries no nonce and OCSP rides plaintext HTTP.
- A verdict must be AFFIRMATIVE — Good or Revoked. "Unknown" means the issuer does not recognise the certificate, which is the answer a mis-issued or forged certificate draws; it is not a pass. (Same rule as CHAOS-53 for the scan sidecar.)
- The responder URL is an SSRF sink. Scheme allow-list + ssrf.PrivateHost before the request, an SSRF-controlled dialer under it, and redirects refused outright — a guard on the first URL alone is bypassed by a 302.
- The work is BOUNDED as an envelope, not per step: at most maxResponders entries, all of them inside one queryBudget, single-flighted per certificate. This runs on the request goroutine inside a TLS handshake.
Index ¶
- type Checker
- func (oc *Checker) CacheLen() int
- func (oc *Checker) CleanupCache()
- func (oc *Checker) Disable()
- func (oc *Checker) Enable()
- func (oc *Checker) Enabled() bool
- func (oc *Checker) FailClosedTotal() int64
- func (oc *Checker) LastFailClosedAt() time.Time
- func (oc *Checker) MalformedTotal() int64
- func (oc *Checker) NotForCertificateTotal() int64
- func (oc *Checker) ResponderBlockedTotal() int64
- func (oc *Checker) RespondersTruncatedTotal() int64
- func (oc *Checker) RevokedTotal() int64
- func (oc *Checker) SingleFlightJoinedTotal() int64
- func (oc *Checker) StaleTotal() int64
- func (oc *Checker) UnauthorizedResponderTotal() int64
- func (oc *Checker) UnknownTotal() int64
- func (oc *Checker) VerifyPeerCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker performs OCSP-based revocation checking for TLS connections.
func New ¶
func New() *Checker
New returns a Checker with an empty verdict cache (disabled until Enable).
func (*Checker) CleanupCache ¶
func (oc *Checker) CleanupCache()
CleanupCache evicts expired entries from the OCSP cache.
func (*Checker) FailClosedTotal ¶ added in v1.0.48
FailClosedTotal returns the number of times a peer certificate was treated as revoked because no OCSP responder listed on it produced a usable, affirmative verdict.
func (*Checker) LastFailClosedAt ¶ added in v1.0.48
LastFailClosedAt returns the time of the most recent fail-closed event, or the zero time if none has occurred.
func (*Checker) MalformedTotal ¶ added in v1.0.228
MalformedTotal counts responses discarded as unintelligible — unparseable DER, a bad signature, an HTML error page. A broken responder, not a hostile one; see NotForCertificateTotal for the accusation.
func (*Checker) NotForCertificateTotal ¶ added in v1.0.228
NotForCertificateTotal counts signed responses discarded because they were about a different certificate than the one being checked. Sustained growth means something is answering with borrowed responses — the revocation-bypass shape CHAOS-65 closed.
func (*Checker) ResponderBlockedTotal ¶ added in v1.0.228
ResponderBlockedTotal counts responder URLs refused before any request was made (disallowed scheme, or an address inside a private range).
func (*Checker) RespondersTruncatedTotal ¶ added in v1.0.228
RespondersTruncatedTotal counts certificates whose AIA responder list was longer than maxResponders.
func (*Checker) RevokedTotal ¶ added in v1.0.48
RevokedTotal returns the number of times an OCSP responder confirmed a peer certificate as actually revoked.
func (*Checker) SingleFlightJoinedTotal ¶ added in v1.0.228
SingleFlightJoinedTotal counts handshakes that waited on another handshake's in-progress query instead of starting their own.
func (*Checker) StaleTotal ¶ added in v1.0.228
StaleTotal counts responses discarded as outside their validity window (replay, or a badly skewed clock on either end).
func (*Checker) UnauthorizedResponderTotal ¶ added in v1.0.228
UnauthorizedResponderTotal counts responses whose signer is not an RFC 6960 authorized responder for the issuer — most importantly a certificate signing a verdict about itself.
func (*Checker) UnknownTotal ¶ added in v1.0.228
UnknownTotal counts responders that answered "unknown" — the issuer does not recognise the certificate.
func (*Checker) VerifyPeerCertificate ¶
func (oc *Checker) VerifyPeerCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
VerifyPeerCertificate is a tls.Config.VerifyPeerCertificate callback that checks OCSP revocation status for the peer's leaf certificate.