Module x509_parser::pem
source · Expand description
Decoding functions for PEM-encoded data
Examples
Parsing a certificate in PEM format:
use x509_parser::pem::pem_to_der;
use x509_parser::parse_x509_der;
static IGCA_PEM: &'static [u8] = include_bytes!("../assets/IGC_A.pem");
let res = pem_to_der(IGCA_PEM);
match res {
Ok((rem, pem)) => {
assert!(rem.is_empty());
//
assert_eq!(pem.label, String::from("CERTIFICATE"));
//
let res_x509 = parse_x509_der(&pem.contents);
assert!(res_x509.is_ok());
},
_ => panic!("PEM parsing failed: {:?}", res),
}
Structs
Representation of PEM data
Functions
Read a PEM-encoded structure, and decode the base64 data