Crate x509_parser
source ·Expand description
X.509 Parser
A X.509 (RFC5280) parser, implemented with the nom parser combinator framework.
The code is available on Github and is part of the Rusticata project.
The main parsing method is parse_x509_der
, which takes a DER-encoded
certificate as input, and builds a X509Certificate
object.
For PEM-encoded certificates, use the pem
module.
Examples
Parsing a certificate in DER format:
use x509_parser::parse_x509_der;
static IGCA_DER: &'static [u8] = include_bytes!("../assets/IGC_A.der");
let res = parse_x509_der(IGCA_DER);
match res {
Ok((rem, cert)) => {
assert!(rem.is_empty());
//
assert_eq!(cert.tbs_certificate.version, 2);
},
_ => panic!("x509 parsing failed: {:?}", res),
}
Re-exports
pub use x509::*;
Modules
X.509 errors
X.509 helper objects definitions: OID, short and long names, NID (internal ID)
Decoding functions for PEM-encoded data
X.509 objects
Structs
Identifies whether the subject of the certificate is a CA, and the max validation depth.