From eccf90a5343cbc093eb94f0fc9d0bc0778117613 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 28 Aug 2017 18:40:16 -1000 Subject: [PATCH] Remove `danger` feature & the API it controls. The singular purpose of this crate should be to integrate Tokio and Rustls. Therefore, any feature that isn't about making Rustls work nicely with Tokio should be assumed a priori to be out of scope. In particular, it is out of scope for tokio-rustls to provide APIs to control SNI behavior. Instead, the application should configure Rustls's SNI behavior using Rustls's configuration APIs, and pass the configuration to tokio-rustls. Similarly, it is out of scope for tokio-rustls to provide APIs to control the certificate validation behavior. Instead, the application should configure certificate validation using Rustls's APIs. Perhaps there should be a crate that makes it convenient to do "dangerous" certificate validation, but IMO that shouldn't be tokio-rustls, but a different one. FWIW, the `danger` API was inherited from tokio-tls, and I'm working on making an analogous change there. --- Cargo.toml | 3 --- src/lib.rs | 29 ----------------------------- tests/test.rs | 21 ++++----------------- 3 files changed, 4 insertions(+), 49 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 796d24f..a739599 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,9 +14,6 @@ categories = ["asynchronous", "cryptography", "network-programming"] travis-ci = { repository = "quininer/tokio-rustls" } appveyor = { repository = "quininer/tokio-rustls" } -[features] -danger = [ "rustls/dangerous_configuration" ] - [dependencies] futures = "0.1" tokio-io = "0.1" diff --git a/src/lib.rs b/src/lib.rs index 978eb6c..12cdf53 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,11 +22,6 @@ pub trait ClientConfigExt { fn connect_async(&self, domain: &str, stream: S) -> ConnectAsync where S: AsyncRead + AsyncWrite; - - #[cfg(feature = "danger")] - fn danger_connect_async_without_providing_domain_for_certificate_verification_and_server_name_indication(&self, stream: S) - -> ConnectAsync - where S: AsyncRead + AsyncWrite; } /// Extension trait for the `Arc` type in the `rustls` crate. @@ -53,30 +48,6 @@ impl ClientConfigExt for Arc { { connect_async_with_session(stream, ClientSession::new(self, domain)) } - - #[cfg(feature = "danger")] - fn danger_connect_async_without_providing_domain_for_certificate_verification_and_server_name_indication(&self, stream: S) - -> ConnectAsync - where S: AsyncRead + AsyncWrite - { - use rustls::{ ServerCertVerifier, RootCertStore, Certificate, ServerCertVerified, TLSError }; - - struct NoCertVerifier; - impl ServerCertVerifier for NoCertVerifier { - fn verify_server_cert(&self, _: &RootCertStore, _: &[Certificate], _: &str, _: &[u8]) - -> Result - { - Ok(ServerCertVerified::assertion()) - } - } - - let mut client_config = ClientConfig::new(); - client_config.clone_from(self); - client_config.dangerous() - .set_certificate_verifier(Arc::new(NoCertVerifier)); - - Arc::new(client_config).connect_async("", stream) - } } #[inline] diff --git a/tests/test.rs b/tests/test.rs index ecf659d..86c715e 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -60,7 +60,7 @@ fn start_server(cert: Vec, rsa: PrivateKey) -> SocketAddr { recv.recv().unwrap() } -fn start_client(addr: &SocketAddr, domain: Option<&str>, chain: Option>>) -> io::Result<()> { +fn start_client(addr: &SocketAddr, domain: &str, chain: Option>>) -> io::Result<()> { let mut config = ClientConfig::new(); if let Some(mut chain) = chain { config.root_store.add_pem_file(&mut chain).unwrap(); @@ -72,17 +72,7 @@ fn start_client(addr: &SocketAddr, domain: Option<&str>, chain: Option