A Rust CLI tool that parses and prints X.509 certificate information in both human-readable and PEM formats.
cargo run -- <certificate_file>The tool accepts certificates in DER or PEM format.
The x509_certificate_printer crate exposes a PrettyPrinter trait:
use x509_certificate_printer::PrettyPrinter;
use x509_parser::prelude::*;
let der_cert = std::fs::read("cert.der")?;
let (_, x509) = parse_x509_certificate(&der_cert)?;
println!("{}", x509.pretty_print());
println!("{}", x509.to_pem());pretty_print(&self) -> String- Returns human-readable certificate detailsto_pem(&self) -> String- Returns PEM-encoded certificate
This code is verbatim taken from x509-parser/examples/print-cert.rs and AI-refactored into a library with a CLI interface.