expression
Reject malformed trust-anchor data
Check whether a supplied certificate can be converted into a trust anchor. Successful parsing alone does not establish that the certificate is authorized for your trust policy. The fixture supplies deliberately invalid noncertificate bytes. External crate example; candidate dependency is not approved for deployment. Expected stdout (not executed): true true Common mistake: Ignoring a root-loading error and proceeding with an unintended trust store.
Formal Syntax & Structure
rust syntaxrust
roots.add(CertificateDer::from(bytes)) -> Result<(), Error>Working Example
Example Snippetrust
fn main() { use rustls::{RootCertStore, pki_types::CertificateDer}; let mut roots = RootCertStore::empty(); let bad = CertificateDer::from(vec![0u8, 1, 2]); println!("{} {}", roots.add(bad).is_err(), roots.is_empty());}