Enum x509_parser::error::X509Error
source · [−]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
sourceimpl Error for X509Error
impl Error for X509Error
sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl<'a> FromDer<'a, X509Error> for X509Certificate<'a>
impl<'a> FromDer<'a, X509Error> for X509Certificate<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
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),
}
sourceimpl<'a> FromDer<'a, X509Error> for TbsCertificate<'a>
impl<'a> FromDer<'a, X509Error> for TbsCertificate<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, TbsCertificate<'a>>
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 -- }
sourceimpl<'a> FromDer<'a, X509Error> for NameConstraints<'a>
impl<'a> FromDer<'a, X509Error> for NameConstraints<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for PolicyMappings<'a>
impl<'a> FromDer<'a, X509Error> for PolicyMappings<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for X509Extension<'a>
impl<'a> FromDer<'a, X509Error> for X509Extension<'a>
Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING }
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
fn from_der(i: &'a [u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for AuthorityKeyIdentifier<'a>
impl<'a> FromDer<'a, X509Error> for AuthorityKeyIdentifier<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for BasicConstraints
impl<'a> FromDer<'a, X509Error> for BasicConstraints
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for KeyIdentifier<'a>
impl<'a> FromDer<'a, X509Error> for KeyIdentifier<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for NSCertType
impl<'a> FromDer<'a, X509Error> for NSCertType
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for AuthorityInfoAccess<'a>
impl<'a> FromDer<'a, X509Error> for AuthorityInfoAccess<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for InhibitAnyPolicy
impl<'a> FromDer<'a, X509Error> for InhibitAnyPolicy
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for PolicyConstraints
impl<'a> FromDer<'a, X509Error> for PolicyConstraints
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for Validity
impl<'a> FromDer<'a, X509Error> for Validity
sourcefn from_der(i: &[u8]) -> X509Result<'_, Self>
fn from_der(i: &[u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for SubjectAlternativeName<'a>
impl<'a> FromDer<'a, X509Error> for SubjectAlternativeName<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for IssuerAlternativeName<'a>
impl<'a> FromDer<'a, X509Error> for IssuerAlternativeName<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for RSAPublicKey<'a>
impl<'a> FromDer<'a, X509Error> for RSAPublicKey<'a>
sourcefn from_der(bytes: &'a [u8]) -> X509Result<'a, Self>
fn from_der(bytes: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for CertificateRevocationList<'a>
impl<'a> FromDer<'a, X509Error> for CertificateRevocationList<'a>
CertificateList ::= SEQUENCE { tbsCertList TBSCertList, signatureAlgorithm AlgorithmIdentifier, signatureValue BIT STRING }
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
fn from_der(i: &'a [u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for TbsCertList<'a>
impl<'a> FromDer<'a, X509Error> for TbsCertList<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
fn from_der(i: &'a [u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for RevokedCertificate<'a>
impl<'a> FromDer<'a, X509Error> for RevokedCertificate<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
fn from_der(i: &'a [u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for ASN1Time
impl<'a> FromDer<'a, X509Error> for ASN1Time
sourcefn from_der(i: &[u8]) -> X509Result<'_, Self>
fn from_der(i: &[u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for X509Version
impl<'a> FromDer<'a, X509Error> for X509Version
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for AttributeTypeAndValue<'a>
impl<'a> FromDer<'a, X509Error> for AttributeTypeAndValue<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for RelativeDistinguishedName<'a>
impl<'a> FromDer<'a, X509Error> for RelativeDistinguishedName<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
fn from_der(i: &'a [u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for X509CertificationRequest<'a>
impl<'a> FromDer<'a, X509Error> for X509CertificationRequest<'a>
CertificationRequest ::= SEQUENCE { certificationRequestInfo CertificationRequestInfo, signatureAlgorithm AlgorithmIdentifier{{ SignatureAlgorithms }}, signature BIT STRING }
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for SubjectPublicKeyInfo<'a>
impl<'a> FromDer<'a, X509Error> for SubjectPublicKeyInfo<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
fn from_der(i: &'a [u8]) -> X509Result<'_, Self>
Parse the SubjectPublicKeyInfo struct portion of a DER-encoded X.509 Certificate
sourceimpl<'a> FromDer<'a, X509Error> for X509Name<'a>
impl<'a> FromDer<'a, X509Error> for X509Name<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
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
sourceimpl<'a> FromDer<'a, X509Error> for X509CertificationRequestInfo<'a>
impl<'a> FromDer<'a, X509Error> for X509CertificationRequestInfo<'a>
CertificationRequestInfo ::= SEQUENCE { version INTEGER { v1(0) } (v1,...), subject Name, subjectPKInfo SubjectPublicKeyInfo{{ PKInfoAlgorithms }}, attributes [0] Attributes{{ CRIAttributes }} }
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, Self>
fn from_der(i: &'a [u8]) -> X509Result<'_, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for X509CriAttribute<'a>
impl<'a> FromDer<'a, X509Error> for X509CriAttribute<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'_, X509CriAttribute<'_>>
fn from_der(i: &'a [u8]) -> X509Result<'_, X509CriAttribute<'_>>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for ExtensionRequest<'a>
impl<'a> FromDer<'a, X509Error> for ExtensionRequest<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for GeneralName<'a>
impl<'a> FromDer<'a, X509Error> for GeneralName<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for KeyUsage
impl<'a> FromDer<'a, X509Error> for KeyUsage
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'a> FromDer<'a, X509Error> for ExtendedKeyUsage<'a>
impl<'a> FromDer<'a, X509Error> for ExtendedKeyUsage<'a>
sourcefn from_der(i: &'a [u8]) -> X509Result<'a, Self>
fn from_der(i: &'a [u8]) -> X509Result<'a, Self>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<'ber, 'a> FromDer<'ber, X509Error> for AlgorithmIdentifier<'a> where
'ber: 'a,
impl<'ber, 'a> FromDer<'ber, X509Error> for AlgorithmIdentifier<'a> where
'ber: 'a,
sourcefn from_der(bytes: &'ber [u8]) -> ParseResult<'ber, Self, X509Error>
fn from_der(bytes: &'ber [u8]) -> ParseResult<'ber, Self, X509Error>
Attempt to parse input bytes into a DER object (enforcing constraints)
sourceimpl<I> ParseError<I> for X509Error
impl<I> ParseError<I> for X509Error
sourceimpl<'a> Parser<&'a [u8], TbsCertificate<'a>, X509Error> for TbsCertificateParser
impl<'a> Parser<&'a [u8], TbsCertificate<'a>, X509Error> for TbsCertificateParser
sourcefn parse(
&mut self,
input: &'a [u8]
) -> IResult<&'a [u8], TbsCertificate<'a>, X509Error>
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 Read more
sourcefn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
fn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
Maps a function over the result of a parser
sourcefn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
Creates a second parser from the output of the first one, then apply over the rest of the input
sourcefn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
Applies a second parser over the output of the first one
sourcefn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
fn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
Applies a second parser after the first one, return their results as a tuple
sourceimpl<'a> Parser<&'a [u8], X509Certificate<'a>, X509Error> for X509CertificateParser
impl<'a> Parser<&'a [u8], X509Certificate<'a>, X509Error> for X509CertificateParser
sourcefn parse(
&mut self,
input: &'a [u8]
) -> IResult<&'a [u8], X509Certificate<'a>, X509Error>
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 Read more
sourcefn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
fn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
Maps a function over the result of a parser
sourcefn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
Creates a second parser from the output of the first one, then apply over the rest of the input
sourcefn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
Applies a second parser over the output of the first one
sourcefn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
fn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
Applies a second parser after the first one, return their results as a tuple
sourceimpl<'a> Parser<&'a [u8], X509Extension<'a>, X509Error> for X509ExtensionParser
impl<'a> Parser<&'a [u8], X509Extension<'a>, X509Error> for X509ExtensionParser
sourcefn parse(
&mut self,
input: &'a [u8]
) -> IResult<&'a [u8], X509Extension<'a>, X509Error>
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 Read more
sourcefn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
fn map<G, O2>(self, g: G) -> Map<Self, G, O> where
G: Fn(O) -> O2,
Maps a function over the result of a parser
sourcefn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
fn flat_map<G, H, O2>(self, g: G) -> FlatMap<Self, G, O> where
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
Creates a second parser from the output of the first one, then apply over the rest of the input
sourcefn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
fn and_then<G, O2>(self, g: G) -> AndThen<Self, G, O> where
G: Parser<O, O2, E>,
Applies a second parser over the output of the first one
sourcefn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
fn and<G, O2>(self, g: G) -> And<Self, G> where
G: Parser<I, O2, E>,
Applies a second parser after the first one, return their results as a tuple
impl StructuralPartialEq for X509Error
Auto Trait Implementations
impl RefUnwindSafe for X509Error
impl Send for X509Error
impl Sync for X509Error
impl Unpin for X509Error
impl UnwindSafe for X509Error
Blanket Implementations
sourceimpl<'a, T, E> AsTaggedExplicit<'a, E> for T where
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for T where
T: 'a,
sourceimpl<'a, T, E> AsTaggedImplicit<'a, E> for T where
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for T where
T: 'a,
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more