mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
return count of trusted certificates from shellchat net tls probe & shellchat net tls mozilla
This commit is contained in:
parent
579f2c36e8
commit
53b002ad9c
2 changed files with 13 additions and 9 deletions
|
|
@ -30,11 +30,12 @@ pub fn shellchat<'a>(
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
let mut i = 0;
|
let mut count = 0;
|
||||||
for rota in rotas {
|
for rota in rotas {
|
||||||
crate::save_cert(format!("webpki-root-{i}").as_str(), &rota).unwrap();
|
crate::save_cert(format!("webpki-root-{count}").as_str(), &rota).unwrap();
|
||||||
i += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
|
write!(ret, "trusted {count} certificates").ok();
|
||||||
}
|
}
|
||||||
// probe establishes a tls connection to the supplied host, extracts the
|
// probe establishes a tls connection to the supplied host, extracts the
|
||||||
// certificates offered and immediately closes the connection.
|
// certificates offered and immediately closes the connection.
|
||||||
|
|
@ -77,8 +78,11 @@ pub fn shellchat<'a>(
|
||||||
conn.send_close_notify();
|
conn.send_close_notify();
|
||||||
|
|
||||||
match conn.peer_certificates() {
|
match conn.peer_certificates() {
|
||||||
Some(certificates) => check_trust(certificates),
|
Some(certificates) => {
|
||||||
None => false,
|
let count = check_trust(certificates);
|
||||||
|
write!(ret, "trusted {count} certificates").ok();
|
||||||
|
}
|
||||||
|
None => (),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ const CURRENT_VERSION_KEY: &str = "__version";
|
||||||
|
|
||||||
// presents a modal to the user to select trusted tls certificates
|
// presents a modal to the user to select trusted tls certificates
|
||||||
// and saves the selected certificates to the pddb
|
// and saves the selected certificates to the pddb
|
||||||
// returns false if no certificates are trusted - and true otherwise
|
// returns a count of trusted certificates
|
||||||
pub fn check_trust(certificates: &[Certificate]) -> bool {
|
pub fn check_trust(certificates: &[Certificate]) -> usize {
|
||||||
let xns = XousNames::new().unwrap();
|
let xns = XousNames::new().unwrap();
|
||||||
let modals = Modals::new(&xns).unwrap();
|
let modals = Modals::new(&xns).unwrap();
|
||||||
|
|
||||||
|
|
@ -82,11 +82,11 @@ pub fn check_trust(certificates: &[Certificate]) -> bool {
|
||||||
.expect("modal failed");
|
.expect("modal failed");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
trusted.len() > 0
|
trusted.len()
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
log::error!("get_checkbox failed");
|
log::error!("get_checkbox failed");
|
||||||
false
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue