pub struct OcspChecker<V> { /* private fields */ }ocsp only.Expand description
Offline OCSP-based revocation checker.
Parses a pre-fetched DER-encoded OCSP response, verifies its signature
against the issuer’s SPKI, checks the validity window of the matching
SingleResponse, and reports the certificate’s
revocation status.
§Feature
Only available when the ocsp feature is enabled.
§Supported responder shapes
- Direct (RFC 6960 §4.2.2.2): the response is signed by the cert’s
issuer CA.
ResponderIdmatches the issuer’s name or SHA-1(SPKI); the response signature verifies against the issuer’s SPKI. - CA Designated Responder (RFC 6960 §4.2.2.2, “delegated”): the
response is signed by a separate responder certificate embedded in
the response’s
certsfield. The responder cert MUST be issued directly by the same CA, MUST carryid-kp-OCSPSigningExtended Key Usage, MUST have a validity period containing the response’sproducedAt, and the issuer’s signature on it MUST verify against the issuer’s SPKI. Failures map to distinct error variants (Error::OcspResponderEkuMissing,Error::OcspResponderEkuMalformed,Error::OcspResponderCertNotIssuedByCa,Error::OcspResponderCertExpired,Error::OcspResponderCertSigInvalid). - The
id-pkix-ocsp-nocheckextension on a delegate cert (RFC 6960 §4.2.2.2.1) is not parsed by this crate: the checker is single-shot and never recurses into the delegate’s revocation regardless of the extension. Callers wrapping this checker in a chain validator MUST honorocsp-nocheckthemselves to prevent infinite recursion.
§Limitations
- Trusted Responder (third RFC 6960 case — a responder whose key
the requester trusts out-of-band) is not modeled. Callers needing
it can supply the trusted responder cert as the
issuerargument. - No OCSP request generation. The response DER must be supplied at
construction time; the checker is offline. The OCSP
nonceextension is therefore not generated or checked. - No AIA-based responder discovery (RFC 6960 §3.1). The
AuthorityInfoAccessextension’sid-ad-ocspURL is not consulted — the caller is responsible for fetching the response out-of-band. See the plannedpkix-revocation-httpcrate for online responder support.
§Behavior
SingleResponsematching uses both serial number and theCertIDissuerNameHash/issuerKeyHashfields (RFC 6960 §4.1.1). An OCSP response from a different CA with the same serial number will be rejected by the hash checks.- The
ResponderIdfield is verified against the issuer identity per RFC 6960 §2.2:byNameis compared against the issuer’s subject DN usingpkix_path::names_match;byKeyis compared against SHA-1 of the issuer’s SPKIsubjectPublicKeybit string. - If no
SingleResponsematches the certificate’s serial number,OcspStatusUnknownis returned (hard-fail). RevocationChecker::check_revocation_against_anchoris overridden. For the certificate issued directly by a trust anchor, the checker uses the anchor’s subject DN and SPKI to verify the OCSP response. The response DER must be supplied at construction time; this method always attempts to verify it against the anchor.
Implementations§
Source§impl<V: SignatureVerifier> OcspChecker<V>
impl<V: SignatureVerifier> OcspChecker<V>
Sourcepub fn new(
response_der: impl AsRef<[u8]>,
now_unix: u64,
verifier: V,
) -> Result<Self>
pub fn new( response_der: impl AsRef<[u8]>, now_unix: u64, verifier: V, ) -> Result<Self>
Create a new OcspChecker.
response_der— DER-encodedOCSPResponse(anyAsRef<[u8]>, e.g.Vec<u8>or&[u8])now_unix— current time as seconds since the Unix epochverifier— signature verifier used to authenticate the OCSP response
The response is parsed once at construction time; subsequent
RevocationChecker::check_revocation calls reuse the cached
BasicOcspResponse.
§Errors
Returns Error::OcspParseError if response_der cannot be DER-decoded
or Error::OcspMalformed if the response status is non-Successful,
responseBytes is absent, or the inner responseType is not
id-pkix-ocsp-basic.
Trait Implementations§
Source§impl<V: Clone> Clone for OcspChecker<V>
impl<V: Clone> Clone for OcspChecker<V>
Source§fn clone(&self) -> OcspChecker<V>
fn clone(&self) -> OcspChecker<V>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<V: Debug> Debug for OcspChecker<V>
impl<V: Debug> Debug for OcspChecker<V>
Source§impl<V: SignatureVerifier> RevocationChecker for OcspChecker<V>
impl<V: SignatureVerifier> RevocationChecker for OcspChecker<V>
Source§fn check_revocation_against_anchor(
&self,
cert: &Certificate,
anchor: &TrustAnchor,
) -> Result<()>
fn check_revocation_against_anchor( &self, cert: &Certificate, anchor: &TrustAnchor, ) -> Result<()>
Check revocation for cert issued directly by a trust anchor.
Parses the pre-loaded OCSP response and verifies it against the anchor’s
SPKI and subject DN. The anchor fields (subject and
subject_public_key_info) are used in place of the missing issuer
Certificate.
§Limitations
OCSP responder discovery via the Authority Information Access extension
(RFC 6960 §3.1) is not implemented. The response DER must be supplied
at construction time and is always verified. If the serial number is
not found in the response, Error::OcspStatusUnknown is returned.
Source§fn check_revocation(
&self,
cert: &Certificate,
issuer: &Certificate,
) -> Result<()>
fn check_revocation( &self, cert: &Certificate, issuer: &Certificate, ) -> Result<()>
cert has been revoked. Read more