Trait rocket::mtls::x509::FromDer

pub trait FromDer<'a>: Sized {
    // Required method
    fn from_der(bytes: &'a [u8]) -> Result<(&'a [u8], Self), Err<X509Error>>;
}
Available on crate feature mtls only.
Expand description

Parse a DER-encoded object, 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.

§Example

To parse a certificate and print the subject and issuer:

let res = X509Certificate::from_der(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),
}

Required Methods§

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

Attempt to parse input bytes into a DER object

Object Safety§

This trait is not object safe.

Implementors§

§

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

§

impl<'a> FromDer<'a> for Vec<CRLDistributionPoint<'a>>

§

impl<'a> FromDer<'a> for Vec<PolicyInformation<'a>>

§

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

§

impl<'a> FromDer<'a> for AlgorithmIdentifier<'a>

§

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

§

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

§

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

§

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

§

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

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

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

§

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

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

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

§

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

§

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

§

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

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

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

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