Skip to content

Commit

Permalink
Add an example to print trust anchors.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsha authored and djc committed Oct 13, 2021
1 parent fc11ca2 commit ccdac5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ webpki-roots = "0.22"
ring = "0.16.5"
untrusted = "0.7.0"
rustls = "0.20"
x509-parser = "0.9.2"

[target.'cfg(windows)'.dependencies]
schannel = "0.1.15"
Expand Down
15 changes: 15 additions & 0 deletions examples/print-trust-anchors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Print the Subject of all extracted trust anchors.

use rustls_native_certs;
use std::error::Error;
use x509_parser::prelude::*;

fn main() -> Result<(), Box<dyn Error>> {
for cert in rustls_native_certs::load_native_certs()? {
match parse_x509_certificate(&cert.0) {
Ok((_, cert)) => println!("{}", cert.tbs_certificate.subject),
Err(e) => eprintln!("error parsing certificate: {}", e),
};
}
Ok(())
}

0 comments on commit ccdac5d

Please sign in to comment.