From 26f8628c180f0126de613f792b6306e5ae3b5f26 Mon Sep 17 00:00:00 2001 From: nworbnhoj Date: Tue, 4 Jul 2023 17:10:27 +1000 Subject: [PATCH] delete redundant file --- libs/tls/src/trusted.rs | 57 ----------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 libs/tls/src/trusted.rs diff --git a/libs/tls/src/trusted.rs b/libs/tls/src/trusted.rs deleted file mode 100644 index 3b6c56b40..000000000 --- a/libs/tls/src/trusted.rs +++ /dev/null @@ -1,57 +0,0 @@ -use crate::get_cert; -use crate::{rota::RustlsOwnedTrustAnchor, TLS_TRUSTED_DICT}; -use rustls::RootCertStore; -use std::io::Error; -use std::path::PathBuf; - -pub struct Trusted { - trusted: std::fs::ReadDir, -} - -impl Trusted { - pub fn new() -> Result { - let mut keypath = PathBuf::new(); - keypath.push(TLS_TRUSTED_DICT); - if !std::fs::metadata(&keypath).is_ok() { - log::info!("dict '{}' does NOT exist.. creating it", TLS_TRUSTED_DICT); - std::fs::create_dir_all(&keypath)?; - } - Ok(Self { - trusted: std::fs::read_dir(keypath)?, - }) - } -} - -impl Iterator for Trusted { - type Item = RustlsOwnedTrustAnchor; - - fn next(&mut self) -> Option { - match self.trusted.next() { - Some(Ok(dir_entry)) => match dir_entry.file_name().into_string() { - Ok(key) => { - log::info!("path: {}", key); - get_cert(&key).unwrap_or(None) - } - Err(e) => { - log::warn!("failed to read cert: {:?}", e); - None - } - }, - Some(Err(e)) => { - log::warn!("failed to list trusted certs: {}", e); - None - } - None => None, - } - } -} - -impl Into for Trusted { - fn into(self) -> RootCertStore { - let mut root_store = rustls::RootCertStore::empty(); - let trusted = Trusted::new().unwrap(); - root_store - .add_server_trust_anchors(trusted.map(|t| Into::::into(t))); - root_store - } -}