diff --git a/Cargo.toml b/Cargo.toml index 53c2093..3df2305 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,11 +35,11 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" socks5-impl = "0.5" thiserror = "1.0" -tokio = { version = "1.34", features = ["full"] } +tokio = { version = "1.35", features = ["full"] } tokio-rustls = "0.24" -tokio-tungstenite = { version = "0.20", features = ["rustls-tls-webpki-roots"] } +tokio-tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] } trust-dns-proto = "0.23" -tungstenite = { version = "0.20", features = ["rustls-tls-webpki-roots"] } +tungstenite = { version = "0.21", features = ["rustls-tls-webpki-roots"] } url = "2.4" webpki = { package = "rustls-webpki", version = "0.101", features = [ "alloc", diff --git a/src/tls.rs b/src/tls.rs index 82fde12..4aa2608 100644 --- a/src/tls.rs +++ b/src/tls.rs @@ -1,5 +1,4 @@ -use crate::error::{Error, Result}; -use rustls_pemfile::{certs, rsa_private_keys}; +use crate::error::Result; use std::{ fs::File, io::BufReader, @@ -84,13 +83,11 @@ pub(crate) async fn create_tls_client_stream( } pub(crate) fn server_load_certs(path: &Path) -> Result> { - certs(&mut BufReader::new(File::open(path)?)) - .map_err(|e| Error::from(format!("Certificate error: {e}"))) - .map(|mut certs| certs.drain(..).map(Certificate).collect()) + let certs = rustls_pemfile::certs(&mut BufReader::new(File::open(path)?))?; + Ok(certs.into_iter().map(Certificate).collect()) } pub(crate) fn server_load_keys(path: &Path) -> Result> { - rsa_private_keys(&mut BufReader::new(File::open(path)?)) - .map_err(|e| Error::from(format!("PrivateKey error: {e}"))) - .map(|mut keys| keys.drain(..).map(PrivateKey).collect()) + let keys = rustls_pemfile::rsa_private_keys(&mut BufReader::new(File::open(path)?))?; + Ok(keys.into_iter().map(PrivateKey).collect()) }