refine tls::ota.from(&TrustAnchor)

This commit is contained in:
nworbnhoj 2024-02-28 06:59:19 +10:00
parent faece9783e
commit 7760b02229
2 changed files with 7 additions and 6 deletions

View file

@ -48,7 +48,8 @@ pub fn shellchat<'a>(mut tokens: impl Iterator<Item = &'a str>) -> Result<Option
count = 0;
let tls = Tls::new();
for ta in webpki_roots::TLS_SERVER_ROOTS {
tls.save_ta(&(*ta).clone().into()).unwrap_or_else(|e| log::warn!("{e}"));
let ota = crate::OwnedTrustAnchor::from(ta);
tls.save_ta(&ota).unwrap_or_else(|e| log::warn!("{e}"));
modals.update_progress(count).expect("no progress");
count += 1;
}

View file

@ -91,12 +91,12 @@ impl fmt::Display for OwnedTrustAnchor {
}
}
impl<'a> From<TrustAnchor<'a>> for OwnedTrustAnchor {
fn from(ta: TrustAnchor) -> Self {
impl<'a> From<&TrustAnchor<'a>> for OwnedTrustAnchor {
fn from(ta: &TrustAnchor) -> Self {
Self::from_subject_spki_name_constraints(
ta.subject.as_ref().to_owned(),
ta.subject_public_key_info.as_ref().to_owned(),
ta.name_constraints.map(|nc| nc.as_ref().to_owned()),
ta.subject.as_ref(),
ta.subject_public_key_info.as_ref(),
ta.name_constraints.as_ref().map(|nc| nc.as_ref()),
)
}
}