pub struct X509CertificateParser { /* private fields */ }
Expand description

X.509 Certificate parser

This object is a parser builder, and allows specifying parsing options. Currently, the only option is to control deep parsing of X.509v3 extensions: a parser can decide to skip deep-parsing to be faster (the structure of extensions is still parsed, and the contents can be parsed later using the from_der method from individual extension objects).

This object uses the nom::Parser trait, which must be imported.

Example

To parse a certificate without parsing extensions:

use x509_parser::certificate::X509CertificateParser;
use x509_parser::nom::Parser;

// create a parser that will not parse extensions
let mut parser = X509CertificateParser::new()
    .with_deep_parse_extensions(false);
let res = parser.parse(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),
}

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

A parser takes in input type, and returns a Result containing either the remaining input and the output value, or an error Read more

Maps a function over the result of a parser

Creates a second parser from the output of the first one, then apply over the rest of the input

Applies a second parser over the output of the first one

Applies a second parser after the first one, return their results as a tuple

Applies a second parser over the input if the first one failed

automatically converts the parser’s output and error values to another type, as long as they implement the From trait Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.