Function parse_x509_certificate

Source
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)
375fn handle_certificate(file_name: &str, data: &[u8]) -> io::Result<()> {
376    match parse_x509_certificate(data) {
377        Ok((_, x509)) => {
378            print_x509_info(&x509)?;
379            Ok(())
380        }
381        Err(e) => {
382            let s = format!("Error while parsing {}: {}", file_name, e);
383            if PARSE_ERRORS_FATAL {
384                Err(io::Error::new(io::ErrorKind::Other, s))
385            } else {
386                eprintln!("{}", s);
387                Ok(())
388            }
389        }
390    }
391}