rocket::mtls::x509

Trait 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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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