mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
replace Certificate with CertificateDer
This commit is contained in:
parent
60aa640f23
commit
84200b2cd2
2 changed files with 10 additions and 11 deletions
|
|
@ -2,7 +2,7 @@ use locales::t;
|
|||
use modals::Modals;
|
||||
use rustls::client::WebPkiServerVerifier;
|
||||
use rustls::client::danger::ServerCertVerified;
|
||||
use rustls::pki_types::{ServerName, UnixTime};
|
||||
use rustls::pki_types::{CertificateDer, ServerName, UnixTime};
|
||||
use rustls::{CertificateError, Error, RootCertStore};
|
||||
use xous_names::XousNames;
|
||||
|
||||
|
|
@ -16,8 +16,8 @@ impl rustls::client::ServerCertVerifier for StifledCertificateVerification {
|
|||
/// return ServerCertVerified::assertion()
|
||||
fn verify_server_cert(
|
||||
&self,
|
||||
end_entity: &rustls::Certificate,
|
||||
intermediates: &[rustls::Certificate],
|
||||
end_entity: &CertificateDer,
|
||||
intermediates: &[CertificateDer],
|
||||
server_name: &ServerName,
|
||||
scts: &mut dyn Iterator<Item = &[u8]>,
|
||||
ocsp: &[u8],
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ use rkyv::{
|
|||
ser::{serializers::WriteSerializer, Serializer},
|
||||
Deserialize,
|
||||
};
|
||||
use rustls::{Certificate, ClientConfig, ClientConnection, RootCertStore};
|
||||
use rustls::{ClientConfig, ClientConnection, RootCertStore};
|
||||
use rustls::pki_types::CertificateDer;
|
||||
use sha2::Digest;
|
||||
use x509_parser::prelude::{FromDer, X509Certificate};
|
||||
use xous_names::XousNames;
|
||||
|
|
@ -42,16 +43,14 @@ impl Tls {
|
|||
/// # Returns
|
||||
///
|
||||
/// a count of trusted certificates
|
||||
pub fn trust_modal(&self, certificates: Vec<Certificate>) -> usize {
|
||||
pub fn trust_modal(&self, certificates: Vec<CertificateDer>) -> usize {
|
||||
let xns = XousNames::new().unwrap();
|
||||
let modals = Modals::new(&xns).unwrap();
|
||||
|
||||
let certificates: Vec<(String, X509Certificate)> = certificates
|
||||
.iter()
|
||||
.map(|cert| {
|
||||
let mut hasher = sha2::Sha256::new();
|
||||
hasher.update(&cert);
|
||||
(format!("{:X}", hasher.finalize()), X509Certificate::from_der(cert.as_ref()))
|
||||
X509Certificate::from_der(cert)
|
||||
})
|
||||
.filter(|(_fingerprint, result)| result.is_ok())
|
||||
.map(|(fingerprint, result)| (fingerprint, result.unwrap().1))
|
||||
|
|
@ -239,8 +238,8 @@ impl Tls {
|
|||
/// # Returns
|
||||
///
|
||||
/// true if the certificate is saved in the TLS_TRUSTED_DICT in the pddb
|
||||
pub fn is_trusted_cert(&self, cert: Certificate) -> bool {
|
||||
match X509Certificate::from_der(cert.as_ref()) {
|
||||
pub fn is_trusted_cert(&self, cert: CertificateDer) -> bool {
|
||||
match X509Certificate::from_der(cert) {
|
||||
Ok(result) => self.is_trusted_x509(&result.1),
|
||||
Err(e) => {
|
||||
log::warn!("failed to get x509 from Certificate: {e}");
|
||||
|
|
@ -307,7 +306,7 @@ impl Tls {
|
|||
/// # Returns
|
||||
///
|
||||
/// The TLS chain of trust for the host
|
||||
pub fn probe(&self, host: &str) -> Result<Vec<Certificate>, Error> {
|
||||
pub fn probe(&self, host: &str) -> Result<Vec<CertificateDer>, Error> {
|
||||
log::info!("starting TLS probe");
|
||||
// Attempt to open the tls connection with an empty root_store
|
||||
let root_store = rustls::RootCertStore::empty();
|
||||
|
|
|
|||
Loading…
Reference in a new issue