print_stuff/
print_stuff.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5extern crate nss_certdata_parser;
6
7use std::fs::File;
8use std::env::args;
9use std::io::BufReader;
10
11use nss_certdata_parser::{ObjectIter, CertData, Usage};
12
13fn main() {
14    for path in args().skip(1) {
15        let objs = ObjectIter::new(BufReader::new(File::open(path).unwrap()));
16        let stuff = CertData::from_iter(objs).unwrap();
17        println!("pub const ALL_CERTS: &'static [Certificate<'static>] = &{:#?};",
18                 stuff.certs());
19        println!("pub const TLS_SERVER_TRUST_ROOTS: &'static [Certificate<'static>] = &{:#?};",
20                 stuff.trusted_certs(Usage::TlsServer));
21        println!("pub const TLS_SERVER_DISTRUSTS: &'static [Trust<'static>] = &{:#?};",
22                 stuff.distrusts(Usage::TlsServer));
23    }
24}