Trait x509_parser::traits::FromDer[][src]

pub trait FromDer<'a>: Sized {
    fn from_der(bytes: &'a [u8]) -> X509Result<'a, Self>;
}
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 (see the Validate trait).

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

Attempt to parse input bytes into a DER object

Implementors