Trait rocket::mtls::x509::FromDer

source ·
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§

source

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§

source§

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

source§

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

source§

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

source§

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

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

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

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

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

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

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

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

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

source§

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