parse_x509_certificate

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