expression

Root import: count accepted and rejected certificates

Bulk import is useful for a bundle with multiple candidates. Track accepted and ignored counts, and choose a policy for partial failure. Here both entries are synthetic malformed bytes; no trust anchor is installed. External crate example; candidate dependency is not approved for deployment. Expected stdout (not executed): 0 2 0 Common mistake: Assuming every entry of a certificate bundle was accepted.

Formal Syntax & Structure

rust syntaxrust
roots.add_parsable_certificates(iter) -> (usize, usize)

Working Example

Example Snippetrust
fn main() {    use rustls::{RootCertStore, pki_types::CertificateDer};    let mut roots = RootCertStore::empty();    let input = [CertificateDer::from(vec![0u8]), CertificateDer::from(vec![1u8])];    let (accepted, ignored) = roots.add_parsable_certificates(input);    println!("{accepted} {ignored} {}", roots.len());}
Rust Reference