#[non_exhaustive]pub enum Error {
Show 27 variants
SignatureInvalid {
index: usize,
},
SignatureNotVerified {
index: usize,
reason: VerificationErrorKind,
},
MalformedCertificate {
index: usize,
},
ValidityPeriod {
index: usize,
},
ChainBroken {
index: usize,
},
TrustAnchorRejected {
defect: AnchorDefect,
},
NoTrustedPath,
PathTooLong,
EkuNotPermittedByIssuer {
index: usize,
},
CaEmptySubject {
index: usize,
},
NotCA {
index: usize,
},
KeyUsageMissing {
index: usize,
},
CrlSignMissing {
index: usize,
},
UnhandledCriticalExtension {
index: usize,
},
NoRevAvailProfileViolation {
index: usize,
prohibition: NoRevAvailProhibition,
},
NameConstraintViolation {
index: usize,
},
PolicyViolation {
index: usize,
},
Der(DerError),
ValidityPeriodExceedsMax {
index: usize,
},
AlgorithmNotAllowed {
index: usize,
},
KeyTooSmall {
index: usize,
},
MissingSan,
MissingRfc822San,
MissingEku,
MissingLeafPolicyOid {
required: ObjectIdentifier,
},
SubjectDnAttrRuleUnmet,
DuplicateCertificate {
first: usize,
second: usize,
},
}Expand description
Errors returned by path validation.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SignatureInvalid
Certificate signature verification failed at the given chain index:
the signature does not verify, or is not a well-formed signature
value (VerificationErrorKind::InvalidSignature).
SignatureNotVerified
The certificate’s signature could not be checked at the given chain
index: the SignatureVerifier does not support its algorithm or
the issuer’s key, or the issuer’s key is malformed. reason says
which; it is never VerificationErrorKind::InvalidSignature.
Fields
reason: VerificationErrorKindWhy the verifier could not check the signature.
MalformedCertificate
A structural encoding error was found in a certificate.
Returned when the outer signatureAlgorithm OID differs from the
inner TBSCertificate.signature OID (RFC 5280 §4.1.1.2; parameters
are not compared, see check_oid_consistency for rationale), when a
certificate carries more than one instance of an extension (RFC 5280
§4.2), and when a security-relevant extension fails to decode.
Fields
index: usizeZero-based index into the chain slice of the malformed certificate.
The underlying der::Error is intentionally not stored here to keep
this variant no_std-compatible and to preserve the stable API shape.
Callers that need the root-cause parse error should validate the
DER certificate independently before calling validate_path.
ValidityPeriod
Certificate validity period check failed (expired or not yet valid).
ChainBroken
Issuer/subject name linkage is broken at the given chain index.
TrustAnchorRejected
The trust anchor certificate itself does not satisfy the profile a CA certificate must meet, or is outside its validity period.
RFC 5280 §6.1 treats the anchor as an input and never examines it,
so the literal algorithm accepts an expired root, a root with no
BasicConstraints, and a root bearing an unrecognised critical
extension. This workspace checks it anyway: a certificate’s own
constraints are the issuer’s statement about what it may be used
for, and honouring them belongs here rather than being left to
whoever assembled the trust store.
Structural defects are caught when the anchor is built
(TrustAnchor::from_cert), so a root that cannot be a CA never
enters a trust store. AnchorDefect::Expired and
AnchorDefect::NotYetValid depend on the clock and are
therefore reported by validate_path.
§Which anchor this describes
The error names a defect, not an anchor, and several anchors may
share a subject name. When more than one is outside its window –
a rollover pair straddling the clock, with the old root past its
notAfter and the new one short of its notBefore –
AnchorDefect::Expired is reported, so the answer does not
depend on the order the trust store supplied its anchors in.
An anchor skipped for its window is reported only when no anchor produced a more specific failure. A trust store holding an expired root beside an unrelated root of the same name whose signature check fails reports the signature failure, and the expiry does not appear. The specific error is the more useful one, but the expiry is not additionally reported.
Fields
defect: AnchorDefectWhich requirement the anchor fails.
NoTrustedPath
No path from the subject certificate to any trust anchor was found.
PathTooLong
Path length exceeds ValidationPolicy::max_path_len.
EkuNotPermittedByIssuer
A CA in the path has an ExtendedKeyUsage that does not permit
what is being asked of the chain below it. See
ValidationPolicy::enforce_ca_eku.
Fields
CaEmptySubject
A certificate that issues another in the path is a CA whose subject names nothing, against RFC 5280 §4.1.2.6.
Distinct from NotCA because the certificate does claim to be a
CA; what it lacks is a name to be one under. See
AnchorDefect::EmptySubject for why an empty DN on a CA is not
merely non-conforming: §6.1.3(a)(4) name chaining compares DNs,
and an empty DN matches an empty DN, so such a CA chains to any
other certificate issued by any other unnamed CA.
NotCA
An intermediate certificate is missing BasicConstraints cA=TRUE.
KeyUsageMissing
An intermediate certificate has a KeyUsage extension with keyCertSign not set.
This error is only returned when a KeyUsage extension is present and the
keyCertSign bit is explicitly absent or zero (RFC 5280 §6.1.4(n): “If a KeyUsage
extension is present, verify that the keyCertSign bit is set.”).
Certificates with no KeyUsage extension are not rejected by this check;
RFC 5280 does not require the extension to be present on CA certificates.
CrlSignMissing
An intermediate certificate has a KeyUsage extension with cRLSign not set.
This error is only returned when
ValidationPolicy::require_crl_sign_on_cas is true and the
intermediate’s KeyUsage extension is present with the cRLSign bit
explicitly absent or zero. Certificates with no KeyUsage extension
are not rejected by this check (RFC 5280 does not require the extension
to be present on CA certificates).
RFC 5280 §6.1 does not mandate this check; it is an opt-in policy that
restores PKITS §4.7.4 / §4.7.5 conformance for callers who treat a CA
cert without cRLSign as non-issuable. Default is off.
Disambiguation: pkix_revocation::Error::CrlSignMissing (same
variant name, different crate) fires during CRL verification when the
CRL signer cert lacks cRLSign (RFC 5280 §6.3.3(f)). This variant
fires during path validation when an intermediate CA cert in the
chain lacks cRLSign and the caller opted into the policy check.
UnhandledCriticalExtension
A critical extension is present that this implementation does not handle.
NoRevAvailProfileViolation
A certificate carries noRevAvail together with something RFC 9608
§3 forbids alongside it.
RFC 9608 §3 lists four prohibitions and ends: “If any of the above are violated in a certificate, then the relying party MUST consider the certificate invalid.” That sentence is addressed to a relying party rather than to an issuer, which is why this is a path-validation error and not only a lint finding.
§Why this is enforced even though pkix-path checks no revocation
noRevAvail asserts that no revocation information will ever be
published. RFC 9608 §4 accordingly skips RFC 5280 §6.1.3 step
(a)(3) for such a certificate, and pkix-chain implements that
skip. §3 is the only thing that makes the skip safe: without it,
any certificate carrying noRevAvail would escape revocation
checking permanently. Enforcing it here — before any revocation
work is driven, and whether or not the caller does any — keeps
the guard with the thing it guards.
A certificate that contradicts itself this way is also one §6.1’s state machine cannot otherwise see: it asserts that no revocation information exists while naming where to fetch it, and two relying parties reading different halves reach different verdicts.
Fields
prohibition: NoRevAvailProhibitionWhich of RFC 9608 §3’s prohibitions the certificate violates.
NameConstraintViolation
Certificate name constraints violated (RFC 5280 §4.2.1.10); index is the 0-based chain position.
Also returned when a constraint is in effect for a name the validator
cannot evaluate: a URI without an authority or with an IP-address
host, a name of an unsupported form (otherName, ediPartyName,
registeredID) under a constraint of that form, a non-IA5String
subject emailAddress, or a SmtpUTF8Mailbox whose domain is not
ASCII.
PolicyViolation
Certificate policy validation failed (RFC 5280 §6.1.5(g)).
Returned when explicit_policy reaches zero and the valid policy tree
is empty, meaning no acceptable certificate policy exists for the chain.
Der(DerError)
ASN.1 / DER encoding or decoding error.
Returned when a structural encoding error is found in a certificate or
when re-encoding TBSCertificate for signature verification fails.
Signature verification now uses heap-allocated encoding (no fixed size
limit), so this error reflects a genuine DER encoding defect in the
certificate, not an implementation size constraint.
The inner DerError is an opaque newtype; the underlying der::Error
is intentionally not exposed so a future major-version bump in the
der crate cannot cascade into a semver break here.
ValidityPeriodExceedsMax
A certificate’s validity period (notAfter − notBefore) exceeds
ValidationPolicy::max_validity_secs.
This check fires for every certificate in the chain, not just the leaf.
AlgorithmNotAllowed
A certificate’s signature algorithm OID is not in
ValidationPolicy::allowed_signature_algs.
The check fires before signature verification so the error is diagnostic
rather than a confusing SignatureInvalid.
KeyTooSmall
An RSA public key’s modulus is smaller than
ValidationPolicy::min_rsa_key_bits bits.
Non-RSA keys (EC, Ed25519, …) are not affected by this check.
MissingSan
The leaf certificate (chain index 0) has no SubjectAltName extension,
or the extension is present but empty.
Only checked when ValidationPolicy::require_subject_alt_name is true.
Intermediate CA certificates are not subject to this check.
MissingRfc822San
The leaf certificate (chain index 0) has a SubjectAltName extension but
none of its entries is an rfc822Name (email address).
Only checked when ValidationPolicy::require_rfc822_san is true.
Intermediate CA certificates are not subject to this check.
MissingEku
The leaf certificate (chain index 0) does not assert all OIDs required
by ValidationPolicy::required_leaf_eku.
anyExtendedKeyUsage (2.5.29.37.0) does not satisfy a specific OID
requirement — each required OID must be listed explicitly.
MissingLeafPolicyOid
The leaf certificate’s CertificatePolicies extension does not assert
a required policy OID from
ValidationPolicy::required_leaf_policy_oids.
anyPolicy (2.5.29.32.0) does not satisfy a specific OID requirement;
each required OID must be listed explicitly in the leaf’s
CertificatePolicies extension.
Distinct from Error::PolicyViolation, which signals failure of the
RFC 5280 §6.1 policy tree (initial_policy_set /
initial_explicit_policy). MissingLeafPolicyOid signals a leaf-only
assertion check that is independent of the policy tree.
Fields
required: ObjectIdentifierThe required policy OID that the leaf does not assert.
SubjectDnAttrRuleUnmet
The leaf certificate’s Subject DN does not satisfy
ValidationPolicy::required_leaf_subject_dn_attrs.
This variant carries no payload; richer “which branch of the rule failed” diagnostics are a non-breaking follow-up.
DuplicateCertificate
Two certificates in the chain share the same (issuer DN, serial number).
Per RFC 5280 §4.1.2.2, the combination of issuer DN and serial number
uniquely identifies a certificate. A cert appearing twice at different
chain positions is a construction error. Returned as a diagnostic rather
than a confusing Error::SignatureInvalid or Error::ChainBroken.
Note: two certificates with the same public key but different issuer+serial are distinct certificates (e.g. cross-signed CAs) and are not rejected by this check.
first and second are the zero-based chain indices of the two duplicates.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Error
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Error
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Error
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()