return count of trusted certificates from shellchat net tls probe & shellchat net tls mozilla

This commit is contained in:
nworbnhoj 2023-06-29 13:10:28 +10:00
parent 579f2c36e8
commit 53b002ad9c
2 changed files with 13 additions and 9 deletions

View file

@ -30,11 +30,12 @@ pub fn shellchat<'a>(
)
})
.collect();
let mut i = 0;
let mut count = 0;
for rota in rotas {
crate::save_cert(format!("webpki-root-{i}").as_str(), &rota).unwrap();
i += 1;
crate::save_cert(format!("webpki-root-{count}").as_str(), &rota).unwrap();
count += 1;
}
write!(ret, "trusted {count} certificates").ok();
}
// probe establishes a tls connection to the supplied host, extracts the
// certificates offered and immediately closes the connection.
@ -77,8 +78,11 @@ pub fn shellchat<'a>(
conn.send_close_notify();
match conn.peer_certificates() {
Some(certificates) => check_trust(certificates),
None => false,
Some(certificates) => {
let count = check_trust(certificates);
write!(ret, "trusted {count} certificates").ok();
}
None => (),
};
}
Err(e) => {

View file

@ -25,8 +25,8 @@ const CURRENT_VERSION_KEY: &str = "__version";
// presents a modal to the user to select trusted tls certificates
// and saves the selected certificates to the pddb
// returns false if no certificates are trusted - and true otherwise
pub fn check_trust(certificates: &[Certificate]) -> bool {
// returns a count of trusted certificates
pub fn check_trust(certificates: &[Certificate]) -> usize {
let xns = XousNames::new().unwrap();
let modals = Modals::new(&xns).unwrap();
@ -82,11 +82,11 @@ pub fn check_trust(certificates: &[Certificate]) -> bool {
.expect("modal failed");
});
});
trusted.len() > 0
trusted.len()
}
_ => {
log::error!("get_checkbox failed");
false
0
}
}
}