ocsp

package
v1.0.521 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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:

  1. 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.
  2. 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.)
  3. 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.
  4. 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

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) CacheLen

func (oc *Checker) CacheLen() int

CacheLen returns the number of entries in the OCSP cache.

func (*Checker) CleanupCache

func (oc *Checker) CleanupCache()

CleanupCache evicts expired entries from the OCSP cache.

func (*Checker) Disable

func (oc *Checker) Disable()

Disable turns off OCSP checking.

func (*Checker) Enable

func (oc *Checker) Enable()

Enable turns on OCSP checking.

func (*Checker) Enabled

func (oc *Checker) Enabled() bool

Enabled returns whether OCSP checking is active.

func (*Checker) FailClosedTotal added in v1.0.48

func (oc *Checker) FailClosedTotal() int64

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

func (oc *Checker) LastFailClosedAt() time.Time

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

func (oc *Checker) MalformedTotal() int64

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

func (oc *Checker) NotForCertificateTotal() int64

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

func (oc *Checker) ResponderBlockedTotal() int64

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

func (oc *Checker) RespondersTruncatedTotal() int64

RespondersTruncatedTotal counts certificates whose AIA responder list was longer than maxResponders.

func (*Checker) RevokedTotal added in v1.0.48

func (oc *Checker) RevokedTotal() int64

RevokedTotal returns the number of times an OCSP responder confirmed a peer certificate as actually revoked.

func (*Checker) SingleFlightJoinedTotal added in v1.0.228

func (oc *Checker) SingleFlightJoinedTotal() int64

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

func (oc *Checker) StaleTotal() int64

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

func (oc *Checker) UnauthorizedResponderTotal() int64

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

func (oc *Checker) UnknownTotal() int64

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL