pub enum X509Error {
Show 22 variants Generic, InvalidVersion, InvalidSerial, InvalidAlgorithmIdentifier, InvalidX509Name, InvalidDate, InvalidSPKI, InvalidSubjectUID, InvalidIssuerUID, InvalidExtensions, InvalidAttributes, DuplicateExtensions, DuplicateAttributes, InvalidSignatureValue, InvalidTbsCertificate, InvalidUserCertificate, InvalidCertificate, SignatureVerificationError, SignatureUnsupportedAlgorithm, InvalidNumber, Der(BerError), NomError(ErrorKind),
}
Expand description

An error that can occur while parsing or validating a certificate.

Variants§

§

Generic

§

InvalidVersion

§

InvalidSerial

§

InvalidAlgorithmIdentifier

§

InvalidX509Name

§

InvalidDate

§

InvalidSPKI

§

InvalidSubjectUID

§

InvalidIssuerUID

§

InvalidExtensions

§

InvalidAttributes

§

DuplicateExtensions

§

DuplicateAttributes

§

InvalidSignatureValue

§

InvalidTbsCertificate

§

InvalidUserCertificate

§

InvalidCertificate

Top-level certificate structure is invalid

§

SignatureVerificationError

§

SignatureUnsupportedAlgorithm

§

InvalidNumber

§

Der(BerError)

§

NomError(ErrorKind)

Trait Implementations§

source§

impl Clone for X509Error

source§

fn clone(&self) -> X509Error

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for X509Error

source§

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

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

impl Display for X509Error

source§

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

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

impl Error for X509Error

source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl From<Err<Error>> for X509Error

source§

fn from(e: Err<BerError>) -> Self

Converts to this type from the input type.
source§

impl From<Err<X509Error>> for X509Error

source§

fn from(e: Err<X509Error>) -> Self

Converts to this type from the input type.
source§

impl From<Error> for X509Error

source§

fn from(source: BerError) -> Self

Converts to this type from the input type.
source§

impl From<ErrorKind> for X509Error

source§

fn from(e: ErrorKind) -> X509Error

Converts to this type from the input type.
source§

impl From<X509Error> for Err<X509Error>

source§

fn from(e: X509Error) -> Err<X509Error>

Converts to this type from the input type.
source§

impl<'a> FromDer<'a, X509Error> for ASN1Time

source§

fn from_der(i: &[u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for AttributeTypeAndValue<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for AuthorityInfoAccess<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for AuthorityKeyIdentifier<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for BasicConstraints

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for CRLDistributionPoints<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for CertificateRevocationList<'a>

CertificateList  ::=  SEQUENCE  {
     tbsCertList          TBSCertList,
     signatureAlgorithm   AlgorithmIdentifier,
     signatureValue       BIT STRING  }
source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for ExtendedKeyUsage<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for ExtensionRequest<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for GeneralName<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for InhibitAnyPolicy

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for IssuerAlternativeName<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for KeyIdentifier<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for KeyUsage

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for NSCertType

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for NameConstraints<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for PolicyConstraints

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for PolicyMappings<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for RSAPublicKey<'a>

source§

fn from_der(bytes: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for RelativeDistinguishedName<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for RevokedCertificate<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for SubjectAlternativeName<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for SubjectPublicKeyInfo<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Parse the SubjectPublicKeyInfo struct portion of a DER-encoded X.509 Certificate

source§

impl<'a> FromDer<'a, X509Error> for TbsCertList<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for TbsCertificate<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, TbsCertificate<'a>>

Parse a DER-encoded TbsCertificate object

TBSCertificate  ::=  SEQUENCE  {
     version         [0]  Version DEFAULT v1,
     serialNumber         CertificateSerialNumber,
     signature            AlgorithmIdentifier,
     issuer               Name,
     validity             Validity,
     subject              Name,
     subjectPublicKeyInfo SubjectPublicKeyInfo,
     issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL,
                          -- If present, version MUST be v2 or v3
     subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL,
                          -- If present, version MUST be v2 or v3
     extensions      [3]  Extensions OPTIONAL
                          -- If present, version MUST be v3 --  }
source§

impl<'a> FromDer<'a, X509Error> for Validity

source§

fn from_der(i: &[u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for X509Certificate<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Parse a DER-encoded X.509 Certificate, and return the remaining of the input and the built object.

The returned object uses zero-copy, and so has the same lifetime as the input.

Note that only parsing is done, not validation.

Certificate  ::=  SEQUENCE  {
        tbsCertificate       TBSCertificate,
        signatureAlgorithm   AlgorithmIdentifier,
        signatureValue       BIT STRING  }
§Example

To parse a certificate and print the subject and issuer:

let res = parse_x509_certificate(DER);
match res {
    Ok((_rem, x509)) => {
        let subject = x509.subject();
        let issuer = x509.issuer();
        println!("X.509 Subject: {}", subject);
        println!("X.509 Issuer: {}", issuer);
    },
    _ => panic!("x509 parsing failed: {:?}", res),
}
source§

impl<'a> FromDer<'a, X509Error> for X509CertificationRequest<'a>

CertificationRequest ::= SEQUENCE {
    certificationRequestInfo CertificationRequestInfo,
    signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }},
    signature          BIT STRING
}
source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for X509CertificationRequestInfo<'a>

CertificationRequestInfo ::= SEQUENCE {
     version       INTEGER { v1(0) } (v1,...),
     subject       Name,
     subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }},
     attributes    [0] Attributes{{ CRIAttributes }}
}
source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for X509CriAttribute<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, X509CriAttribute<'_>>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for X509Extension<'a>

Extension  ::=  SEQUENCE  {
    extnID      OBJECT IDENTIFIER,
    critical    BOOLEAN DEFAULT FALSE,
    extnValue   OCTET STRING  }
source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'a> FromDer<'a, X509Error> for X509Name<'a>

source§

fn from_der(i: &'a [u8]) -> X509Result<'_, Self>

Parse the X.501 type Name, used for ex in issuer and subject of a X.509 certificate

source§

impl<'a> FromDer<'a, X509Error> for X509Version

source§

fn from_der(i: &'a [u8]) -> X509Result<'a, Self>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<'ber, 'a> FromDer<'ber, X509Error> for AlgorithmIdentifier<'a>
where 'ber: 'a,

source§

fn from_der(bytes: &'ber [u8]) -> ParseResult<'ber, Self, X509Error>

Attempt to parse input bytes into a DER object (enforcing constraints)
source§

impl<I> ParseError<I> for X509Error

source§

fn from_error_kind(_input: I, kind: ErrorKind) -> Self

Creates an error from the input position and an ErrorKind
source§

fn append(_input: I, kind: ErrorKind, _other: Self) -> Self

Combines an existing error with a new one created from the input position and an ErrorKind. This is useful when backtracking through a parse tree, accumulating error context on the way
source§

fn from_char(input: I, _: char) -> Self

Creates an error from an input position and an expected character
source§

fn or(self, other: Self) -> Self

Combines two existing errors. This function is used to compare errors generated in various branches of alt.
source§

impl<'a> Parser<&'a [u8], TbsCertificate<'a>, X509Error> for TbsCertificateParser

source§

fn parse( &mut self, input: &'a [u8] ) -> IResult<&'a [u8], TbsCertificate<'a>, X509Error>

A parser takes in input type, and returns a Result containing either the remaining input and the output value, or an error
source§

fn map<G, O2>(self, g: G) -> Map<Self, G, O>
where G: Fn(O) -> O2, Self: Sized,

Maps a function over the result of a parser
source§

fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O>
where G: FnMut(O) -> H, H: Parser<I, O2, E>, Self: Sized,

Creates a second parser from the output of the first one, then apply over the rest of the input
source§

fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O>
where G: Parser<O, O2, E>, Self: Sized,

Applies a second parser over the output of the first one
source§

fn and<G, O2>(self, g: G) -> And<Self, G>
where G: Parser<I, O2, E>, Self: Sized,

Applies a second parser after the first one, return their results as a tuple
source§

fn or<G>(self, g: G) -> Or<Self, G>
where G: Parser<I, O, E>, Self: Sized,

Applies a second parser over the input if the first one failed
source§

fn into<O2, E2>(self) -> Into<Self, O, O2, E, E2>
where O2: From<O>, E2: From<E>, Self: Sized,

automatically converts the parser’s output and error values to another type, as long as they implement the From trait
source§

impl<'a> Parser<&'a [u8], X509Certificate<'a>, X509Error> for X509CertificateParser

source§

fn parse( &mut self, input: &'a [u8] ) -> IResult<&'a [u8], X509Certificate<'a>, X509Error>

A parser takes in input type, and returns a Result containing either the remaining input and the output value, or an error
source§

fn map<G, O2>(self, g: G) -> Map<Self, G, O>
where G: Fn(O) -> O2, Self: Sized,

Maps a function over the result of a parser
source§

fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O>
where G: FnMut(O) -> H, H: Parser<I, O2, E>, Self: Sized,

Creates a second parser from the output of the first one, then apply over the rest of the input
source§

fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O>
where G: Parser<O, O2, E>, Self: Sized,

Applies a second parser over the output of the first one
source§

fn and<G, O2>(self, g: G) -> And<Self, G>
where G: Parser<I, O2, E>, Self: Sized,

Applies a second parser after the first one, return their results as a tuple
source§

fn or<G>(self, g: G) -> Or<Self, G>
where G: Parser<I, O, E>, Self: Sized,

Applies a second parser over the input if the first one failed
source§

fn into<O2, E2>(self) -> Into<Self, O, O2, E, E2>
where O2: From<O>, E2: From<E>, Self: Sized,

automatically converts the parser’s output and error values to another type, as long as they implement the From trait
source§

impl<'a> Parser<&'a [u8], X509Extension<'a>, X509Error> for X509ExtensionParser

source§

fn parse( &mut self, input: &'a [u8] ) -> IResult<&'a [u8], X509Extension<'a>, X509Error>

A parser takes in input type, and returns a Result containing either the remaining input and the output value, or an error
source§

fn map<G, O2>(self, g: G) -> Map<Self, G, O>
where G: Fn(O) -> O2, Self: Sized,

Maps a function over the result of a parser
source§

fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O>
where G: FnMut(O) -> H, H: Parser<I, O2, E>, Self: Sized,

Creates a second parser from the output of the first one, then apply over the rest of the input
source§

fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O>
where G: Parser<O, O2, E>, Self: Sized,

Applies a second parser over the output of the first one
source§

fn and<G, O2>(self, g: G) -> And<Self, G>
where G: Parser<I, O2, E>, Self: Sized,

Applies a second parser after the first one, return their results as a tuple
source§

fn or<G>(self, g: G) -> Or<Self, G>
where G: Parser<I, O, E>, Self: Sized,

Applies a second parser over the input if the first one failed
source§

fn into<O2, E2>(self) -> Into<Self, O, O2, E, E2>
where O2: From<O>, E2: From<E>, Self: Sized,

automatically converts the parser’s output and error values to another type, as long as they implement the From trait
source§

impl PartialEq for X509Error

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for X509Error

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

source§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

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> 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> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.