Skip to content

Commit 0aa1c18

Browse files
committed
Add an example to print trust anchors.
1 parent fc11ca2 commit 0aa1c18

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ webpki-roots = "0.22"
1919
ring = "0.16.5"
2020
untrusted = "0.7.0"
2121
rustls = "0.20"
22+
x509-parser = "0.9.2"
2223

2324
[target.'cfg(windows)'.dependencies]
2425
schannel = "0.1.15"

examples/print-trust-anchors.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Print the Subject of all extracted trust anchors.
2+
3+
use rustls_native_certs;
4+
use std::error::Error;
5+
use x509_parser::prelude::*;
6+
7+
fn main() -> Result<(), Box<dyn Error>> {
8+
for cert in rustls_native_certs::load_native_certs()? {
9+
let (_, cert) = parse_x509_certificate(&cert.0)?;
10+
println!("{}", cert.tbs_certificate.subject);
11+
}
12+
Ok(())
13+
}

0 commit comments

Comments
 (0)