mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
implement Tls.is_trusted_cert() & Tls.is_trusted_x509()
This commit is contained in:
parent
6e1947d3b0
commit
0ca24db2f0
1 changed files with 35 additions and 0 deletions
|
|
@ -260,6 +260,41 @@ impl Tls {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_trusted_cert(&self, cert: Certificate) -> bool {
|
||||
match X509Certificate::from_der(cert.as_ref()) {
|
||||
Ok(result) => self.is_trusted_x509(&result.1),
|
||||
Err(e) => {
|
||||
log::warn!("failed to get x509 from Certificate: {e}");
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_trusted_x509(&self, x509: &X509Certificate) -> bool {
|
||||
let ta = RustlsOwnedTrustAnchor::from(x509);
|
||||
let key = ta.pddb_key();
|
||||
match self.pddb.get(
|
||||
TLS_TRUSTED_DICT,
|
||||
&key,
|
||||
None,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
None::<fn()>,
|
||||
) {
|
||||
// Ok(_) => true,
|
||||
// Err(_) => false,
|
||||
Ok(_) => {
|
||||
log::info!("trusted: {key}");
|
||||
true
|
||||
}
|
||||
Err(_) => {
|
||||
log::info!("UNtrusted: {key}");
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a RootCertStore containing all trusted trust-anchors
|
||||
///
|
||||
pub fn root_store(&self) -> RootCertStore {
|
||||
|
|
|
|||
Loading…
Reference in a new issue