pub struct Pem {
    pub label: String,
    pub contents: Vec<u8>,
}
Expand description

Representation of PEM data

Fields

label: String

The PEM label

contents: Vec<u8>

The PEM decoded data

Implementations

Read the next PEM-encoded structure, and decode the base64 data

Returns the certificate (encoded in DER) and the number of bytes read. Allocates a new buffer for the decoded data.

Note that a PEM file can contain multiple PEM blocks. This function returns the first decoded object, starting from the current reader position. To get all objects, call this function repeatedly until PEMError::MissingHeader is returned.

Examples
let file = std::fs::File::open("assets/certificate.pem").unwrap();
let subject = x509_parser::pem::Pem::read(std::io::BufReader::new(file))
     .unwrap().0
    .parse_x509().unwrap()
    .tbs_certificate.subject.to_string();
assert_eq!(subject, "CN=lists.for-our.info");

Decode the PEM contents into a X.509 object

Returns an iterator over the PEM-encapsulated parts of a buffer

Only the sections enclosed in blocks starting with -----BEGIN xxx----- and ending with -----END xxx----- will be considered. Lines before, between or after such blocks will be ignored.

The iterator is fallible: next() returns a Result<Pem, PEMError> object. An error indicates a block is present but invalid.

If the buffer does not contain any block, iterator will be empty.

Returns an iterator over the PEM-encapsulated parts of a reader

Only the sections enclosed in blocks starting with -----BEGIN xxx----- and ending with -----END xxx----- will be considered. Lines before, between or after such blocks will be ignored.

The iterator is fallible: next() returns a Result<Pem, PEMError> object. An error indicates a block is present but invalid.

If the reader does not contain any block, iterator will be empty.

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

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

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.