From f744d36b3081728f3dd1295d9c9956b54b4967cf Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Mon, 11 Oct 2021 10:08:52 +0200 Subject: [PATCH] Remove now unused module --- src/rustls.rs | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 src/rustls.rs diff --git a/src/rustls.rs b/src/rustls.rs deleted file mode 100644 index eb491dd..0000000 --- a/src/rustls.rs +++ /dev/null @@ -1,47 +0,0 @@ -use rustls::RootCertStore; -use std::io::{Error, ErrorKind}; -use std::io::BufRead; -use crate::RootStoreBuilder; - -/// Like `Result`, but allows for functions that can return partially complete -/// work alongside an error. -/// -/// *This type is available only if the crate is built with the "rustls" feature.* -pub type PartialResult = Result, E)>; - -/// Loads root certificates found in the platform's native certificate -/// store. -/// -/// On success, this returns a `rustls::RootCertStore` loaded with a -/// snapshop of the root certificates found on this platform. This -/// function fails in a platform-specific way, expressed in a `std::io::Error`. -/// -/// This function can be expensive: on some platforms it involves loading -/// and parsing a ~300KB disk file. It's therefore prudent to call -/// this sparingly. -/// -/// *This function is available only if the crate is built with the "rustls" feature.* -pub fn load_native_certs() -> PartialResult { - struct RootCertStoreLoader { - store: RootCertStore, - } - impl RootStoreBuilder for RootCertStoreLoader { - fn load_der(&mut self, der: Vec) -> Result<(), Error> { - self.store.add(&rustls::Certificate(der)) - .map_err(|err| Error::new(ErrorKind::InvalidData, err)) - } - fn load_pem_file(&mut self, rd: &mut dyn BufRead) -> Result<(), Error> { - self.store.add_pem_file(rd) - .map(|_| ()) - .map_err(|()| Error::new(ErrorKind::InvalidData, "could not load PEM file".to_owned())) - } - } - let mut loader = RootCertStoreLoader { - store: RootCertStore::empty(), - }; - match crate::build_native_certs(&mut loader) { - Err(err) if loader.store.is_empty() => Err((None, err)), - Err(err) => Err((Some(loader.store), err)), - Ok(()) => Ok(loader.store), - } -}