Skip to main content

AnchorDefect

Enum AnchorDefect 

Source
#[non_exhaustive]
pub enum AnchorDefect { BasicConstraintsMissing, BasicConstraintsNotCritical, NotCa, EmptySubject, KeyCertSignMissing, UnhandledCriticalExtension, MalformedExtension, NonDerBoolean, DuplicateExtension, Expired, NotYetValid, }
Expand description

Why a trust anchor certificate was refused.

See Error::TrustAnchorRejected for why the anchor is examined at all, given that RFC 5280 §6.1 does not.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

BasicConstraintsMissing

No BasicConstraints extension. RFC 5280 §4.2.1.9 requires one in every CA certificate whose key signs certificates.

§

BasicConstraintsNotCritical

BasicConstraints present but not marked critical, which §4.2.1.9 requires for a CA certificate.

§

NotCa

BasicConstraints present with cA=FALSE: the certificate says it is not a CA, so it cannot be one.

§

EmptySubject

The certificate is a CA and its subject names nothing. RFC 5280 §4.1.2.6: “If the subject is a CA […], then the subject field MUST be populated with a non-empty distinguished name”.

§4.1.2.6 also lets an end entity carry its name only in a critical subjectAltName, with an empty subject. That exception does not extend to a CA, and the reason is structural rather than stylistic: §6.1.3(a)(4) chains a certificate to its issuer by comparing the issuer field against the working issuer name, and an empty DN matches an empty DN. A CA named by nothing therefore issues certificates whose issuer field is also empty, and any such CA chains to any other – name chaining stops distinguishing issuers at all. The SAN cannot stand in, because §6.1.3 never reads a SAN as the working issuer name.

Reported for a CA whatever its subjectAltName says, including a critical one.

§

KeyCertSignMissing

KeyUsage is present and does not assert keyCertSign, so the key is not permitted to sign certificates. Absent KeyUsage is not a defect – §4.2.1.3 leaves every usage permitted then.

§

UnhandledCriticalExtension

A critical extension this implementation does not process. §6.1.4 would reject such a certificate inside the path; the same rule is applied to the anchor.

§

MalformedExtension

An extension’s DER could not be parsed, so what it requires cannot be known.

§

NonDerBoolean

An extension holds a BOOLEAN that is valid BER and not valid DER, so a strict parser cannot read it even though what it says is not in doubt.

X.690 §11.1 requires a DER BOOLEAN with the value TRUE to have every bit of its content octet set, that is 0xFF. BER permits any non-zero octet, and RFC 5280 §4.1 requires certificates to be DER-encoded, so 0x01 is a non-conforming encoding of TRUE.

Reported instead of MalformedExtension because the two call for different responses. A malformed extension is unreadable and might say anything; this one is readable by every lenient parser in the world and says TRUE. A caller seeing this knows the certificate is salvageable by its issuer re-encoding it, and knows that peers using OpenSSL or NSS accept it today – neither of which MalformedExtension conveys.

The certificate is still refused. Reading a non-DER encoding generously would mean deciding that cA is TRUE on the strength of an encoding the profile forbids. Three real certificates in third_party/trust-stores/ encode basicConstraints cA this way, out of 1,923 that encode the boolean at all: two eIDAS roots and Ukraine’s ePassport CSCA.

Detected for basicConstraints, the only extension in this profile carrying a BOOLEAN in its own value.

§

DuplicateExtension

The same extension OID appears more than once. RFC 5280 §4.2: “A certificate MUST NOT include more than one instance of a particular extension.”

Reported in preference to every other defect here, because the extension list is what the rest of the profile check reads and a duplicate makes those reads arbitrary: this crate takes the first instance of an OID, another validator may take the last, and a certificate with two basicConstraints or two KeyUsage values then means different things to different implementations. A real Lenovo UEFI Platform Key carries two critical KeyUsage extensions whose values disagree, one permitting keyCertSign and one permitting only digitalSignature.

validate_path has always rejected such a certificate inside a path, as Error::MalformedCertificate; this is the same rule applied to the anchor.

§

Expired

The anchor’s notAfter is before the validation time.

§

NotYetValid

The anchor’s notBefore is after the validation time.

Trait Implementations§

Source§

impl Clone for AnchorDefect

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for AnchorDefect

Source§

impl Debug for AnchorDefect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AnchorDefect

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for AnchorDefect

Source§

impl Hash for AnchorDefect

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for AnchorDefect

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AnchorDefect

Available on crate feature serde only.
Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AnchorDefect

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.