#[non_exhaustive]pub enum Error {
Show 19 variants
SignatureInvalid {
index: usize,
},
MalformedCertificate {
index: usize,
},
ValidityPeriod {
index: usize,
},
ChainBroken {
index: usize,
},
NoTrustedPath,
PathTooLong,
NotCA {
index: usize,
},
KeyUsageMissing {
index: usize,
},
UnhandledCriticalExtension {
index: usize,
},
NameConstraintViolation {
index: usize,
},
PolicyViolation {
index: usize,
},
Der(DerError),
ValidityPeriodExceedsMax {
index: usize,
},
AlgorithmNotAllowed {
index: usize,
},
KeyTooSmall {
index: usize,
},
MissingSan,
MissingRfc822San,
MissingEku,
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.
MalformedCertificate
A structural encoding error was found in a certificate.
Currently 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.
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.
NoTrustedPath
No path from the subject certificate to any trust anchor was found.
PathTooLong
Path length exceeds ValidationPolicy::max_path_len.
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.
UnhandledCriticalExtension
A critical extension is present that this implementation does not handle.
NameConstraintViolation
Certificate name constraints violated (RFC 5280 §4.2.1.10); index is the 0-based chain position.
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.
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 Error for Error
Available on crate feature std only.
impl Error for Error
std only.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()