From 89bebf0bc6cdddc9566ee003b46f3313cc504073 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Sat, 19 Apr 2025 04:49:28 +0200 Subject: [PATCH] Drop unused `webpki` dependency --- Cargo.toml | 6 ------ src/error/tls/rustls_error.rs | 27 +++------------------------ src/io/tls/rustls_io.rs | 2 +- 3 files changed, 4 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cfc052f9..713b3d50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,11 +62,6 @@ optional = true version = "2.1.0" optional = true -[dependencies.webpki] -version = ">=0.22.1" -features = ["std"] -optional = true - [dependencies.webpki-roots] version = "0.26.1" optional = true @@ -103,7 +98,6 @@ native-tls-tls = ["native-tls", "tokio-native-tls"] rustls-tls = [ "rustls", "tokio-rustls", - "webpki", "webpki-roots", "rustls-pemfile", ] diff --git a/src/error/tls/rustls_error.rs b/src/error/tls/rustls_error.rs index faae88db..d88f3b18 100644 --- a/src/error/tls/rustls_error.rs +++ b/src/error/tls/rustls_error.rs @@ -7,8 +7,7 @@ use rustls::server::VerifierBuilderError; #[derive(Debug)] pub enum TlsError { Tls(rustls::Error), - Pki(webpki::Error), - InvalidDnsName(webpki::InvalidDnsNameError), + InvalidDnsName(rustls::pki_types::InvalidDnsNameError), VerifierBuilderError(VerifierBuilderError), } @@ -30,41 +29,22 @@ impl From for TlsError { } } -impl From for TlsError { - fn from(e: webpki::InvalidDnsNameError) -> Self { +impl From for TlsError { + fn from(e: rustls::pki_types::InvalidDnsNameError) -> Self { TlsError::InvalidDnsName(e) } } -impl From for TlsError { - fn from(e: webpki::Error) -> Self { - TlsError::Pki(e) - } -} - impl From for crate::Error { fn from(e: rustls::Error) -> Self { crate::Error::Io(crate::error::IoError::Tls(e.into())) } } -impl From for crate::Error { - fn from(e: webpki::Error) -> Self { - crate::Error::Io(crate::error::IoError::Tls(e.into())) - } -} - -impl From for crate::Error { - fn from(e: webpki::InvalidDnsNameError) -> Self { - crate::Error::Io(crate::error::IoError::Tls(e.into())) - } -} - impl std::error::Error for TlsError { fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { TlsError::Tls(e) => Some(e), - TlsError::Pki(e) => Some(e), TlsError::InvalidDnsName(e) => Some(e), TlsError::VerifierBuilderError(e) => Some(e), } @@ -75,7 +55,6 @@ impl Display for TlsError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { TlsError::Tls(e) => e.fmt(f), - TlsError::Pki(e) => e.fmt(f), TlsError::InvalidDnsName(e) => e.fmt(f), TlsError::VerifierBuilderError(e) => e.fmt(f), } diff --git a/src/io/tls/rustls_io.rs b/src/io/tls/rustls_io.rs index ad2ec672..143cf066 100644 --- a/src/io/tls/rustls_io.rs +++ b/src/io/tls/rustls_io.rs @@ -85,7 +85,7 @@ impl Endpoint { let stream = stream.take().unwrap(); let server_name = ServerName::try_from(domain.as_str()) - .map_err(|_| webpki::InvalidDnsNameError)? + .map_err(TlsError::InvalidDnsName)? .to_owned(); let connection = tls_connector.connect(server_name, stream).await?;