pub fn parse_x509_certificate(i: &[u8]) -> X509Result<'_, X509Certificate<'_>>
Expand description

Parse a DER-encoded X.509 Certificate, and return the remaining of the input and the built object.

This function is an alias to X509Certificate::from_der. See this function for more information.

For PEM-encoded certificates, use the pem module.

Examples found in repository?
examples/print-cert.rs (line 376)
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
fn handle_certificate(file_name: &str, data: &[u8]) -> io::Result<()> {
    match parse_x509_certificate(data) {
        Ok((_, x509)) => {
            print_x509_info(&x509)?;
            Ok(())
        }
        Err(e) => {
            let s = format!("Error while parsing {}: {}", file_name, e);
            if PARSE_ERRORS_FATAL {
                Err(io::Error::new(io::ErrorKind::Other, s))
            } else {
                eprintln!("{}", s);
                Ok(())
            }
        }
    }
}