From 3efb0544c692948be660ebc26d61177b7705963a Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Tue, 13 Jul 2021 17:46:48 +0900 Subject: [PATCH] Remove the rustls-tls feature flag --- Cargo.toml | 5 ++--- src/client.rs | 11 +++++++++-- src/error.rs | 4 ++-- src/stream.rs | 4 ++-- tests/connection_reset.rs | 11 +++++++++-- 5 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 50c13db..5590546 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,8 @@ all-features = true default = [] native-tls = ["native-tls-crate"] native-tls-vendored = ["native-tls", "native-tls-crate/vendored"] -rustls-tls = ["rustls", "webpki"] -rustls-tls-native-roots = ["rustls-tls", "rustls-native-certs"] -rustls-tls-webpki-roots = ["rustls-tls", "webpki-roots"] +rustls-tls-native-roots = ["rustls", "webpki", "rustls-native-certs"] +rustls-tls-webpki-roots = ["rustls", "webpki", "webpki-roots"] [dependencies] base64 = "0.13.0" diff --git a/src/client.rs b/src/client.rs index 1a473f0..6b9c21c 100644 --- a/src/client.rs +++ b/src/client.rs @@ -50,7 +50,10 @@ mod encryption { } } -#[cfg(all(feature = "rustls-tls", not(feature = "native-tls")))] +#[cfg(all( + any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"), + not(feature = "native-tls") +))] mod encryption { use rustls::ClientConfig; pub use rustls::{ClientSession, StreamOwned}; @@ -96,7 +99,11 @@ mod encryption { } } -#[cfg(not(any(feature = "native-tls", feature = "rustls-tls")))] +#[cfg(not(any( + feature = "native-tls", + feature = "rustls-tls-native-roots", + feature = "rustls-tls-webpki-roots" +)))] mod encryption { use std::net::TcpStream; diff --git a/src/error.rs b/src/error.rs index 6ab7420..d1d176b 100644 --- a/src/error.rs +++ b/src/error.rs @@ -253,11 +253,11 @@ pub enum TlsError { #[error("native-tls error: {0}")] Native(#[from] native_tls_crate::Error), /// Rustls error. - #[cfg(feature = "rustls-tls")] + #[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))] #[error("rustls error: {0}")] Rustls(#[from] rustls::TLSError), /// DNS name resolution error. - #[cfg(feature = "rustls-tls")] + #[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))] #[error("Invalid DNS name: {0}")] Dns(#[from] webpki::InvalidDNSNameError), } diff --git a/src/stream.rs b/src/stream.rs index 4d60405..5edfe03 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -10,7 +10,7 @@ use std::net::TcpStream; #[cfg(feature = "native-tls")] use native_tls_crate::TlsStream; -#[cfg(feature = "rustls-tls")] +#[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))] use rustls::StreamOwned; /// Stream mode, either plain TCP or TLS. @@ -41,7 +41,7 @@ impl NoDelay for TlsStream { } } -#[cfg(feature = "rustls-tls")] +#[cfg(any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"))] impl NoDelay for StreamOwned { fn set_nodelay(&mut self, nodelay: bool) -> IoResult<()> { self.sock.set_nodelay(nodelay) diff --git a/tests/connection_reset.rs b/tests/connection_reset.rs index 7f625be..c14f2ec 100644 --- a/tests/connection_reset.rs +++ b/tests/connection_reset.rs @@ -1,6 +1,10 @@ //! Verifies that the server returns a `ConnectionClosed` error when the connection //! is closed from the server's point of view and drop the underlying tcp socket. -#![cfg(any(feature = "native-tls", feature = "rustls-tls"))] +#![cfg(any( + feature = "native-tls", + feature = "rustls-tls-native-roots", + feature = "rustls-tls-webpki-roots" +))] use std::{ net::{TcpListener, TcpStream}, @@ -15,7 +19,10 @@ use url::Url; #[cfg(feature = "native-tls")] type Sock = WebSocket>>; -#[cfg(all(feature = "rustls-tls", not(feature = "native-tls")))] +#[cfg(all( + any(feature = "rustls-tls-native-roots", feature = "rustls-tls-webpki-roots"), + not(feature = "native-tls") +))] type Sock = WebSocket>>; fn do_test(port: u16, client_task: CT, server_task: ST)