pub fn validate_path<V, C>(
chain: &[C],
anchors: &[TrustAnchor],
policy: &ValidationPolicy,
verifier: &V,
) -> Result<ValidatedPath>where
V: SignatureVerifier,
C: PathCertificate,Expand description
Validate a certificate chain from subject to a trust anchor.
chain must be ordered leaf-first:
chain[0]is the subject (end-entity) certificatechain[1..]are intermediates in issuer order- The last element of
chainmust be issued by one ofanchors
Validation follows RFC 5280 §6.1. Each certificate’s signature is verified
using verifier, with the signing key taken from the next certificate in
the chain (or the matching trust anchor for the last cert).
§Including the root certificate
The self-signed certificate of the trust anchor may be passed as the last
element of chain. It is then processed as path certificate 1 of
RFC 5280 §6.1 rather than skipped: its own signature, validity period,
BasicConstraints, KeyUsage, name constraints and policy extensions all
apply. In particular a root without a CertificatePolicies extension
(the common case) reduces the policy tree to NULL (§6.1.3(e)), so a
path that requires an explicit policy fails when the root is included
and succeeds when it is supplied only as the anchor. Pass the root only
in anchors unless its constraints are meant to apply as a path
certificate.
§Errors
Returns Err(Error::NoTrustedPath) if chain is empty or anchors is
empty. On success, chain is therefore guaranteed to contain at least one
certificate.
Returns Err on the first RFC 5280 §6.1 check failure. The error variant
includes the chain index of the failing certificate where applicable.
§The validation moment is already fixed
This takes a &ValidationPolicy, so the moment validity periods are
evaluated at was chosen when that policy was built. See
ValidationPolicy::new for what now_unix does and does not
select – in short, it is the clock and not a selector for which
version of the rules applies.
§Limitations
See crate-level documentation for current scope limits.