x509-parser 0.3.0

Parser for the X.509 v3 format (RFC 5280 certificates)
Documentation

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 x509_parser, 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:

# extern crate nom;
# #[macro_use] extern crate x509_parser;
use x509_parser::x509_parser;

static IGCA_DER: &'static [u8] = include_bytes!("../assets/IGC_A.der");

# fn main() {
let res = x509_parser(IGCA_DER);
match res {
    Ok((rem, cert)) => {
        assert!(rem.is_empty());
        //
        assert_eq!(cert.tbs_certificate.version, 2);
    },
    _ => panic!("x509 parsing failed: {:?}", res),
}
# }