From f6f9e1fcdb1fcefad69adc8c4cb3f71e5d80738f Mon Sep 17 00:00:00 2001 From: Sven-Hendrik Haase Date: Fri, 4 Oct 2019 07:30:13 +0200 Subject: [PATCH] Add an error message if we receive a non-hostname-based dest This is more helpful than an unwrap and at least points users at the right location. Upstream issue is https://github.com/briansmith/webpki/issues/54 --- actix-connect/src/ssl/rustls.rs | 3 ++- actix-connect/tests/test_connect.rs | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/actix-connect/src/ssl/rustls.rs b/actix-connect/src/ssl/rustls.rs index 7d6f5720..465ef1e4 100644 --- a/actix-connect/src/ssl/rustls.rs +++ b/actix-connect/src/ssl/rustls.rs @@ -94,7 +94,8 @@ where fn call(&mut self, stream: Connection) -> Self::Future { trace!("SSL Handshake start for: {:?}", stream.host()); let (io, stream) = stream.replace(()); - let host = DNSNameRef::try_from_ascii_str(stream.host()).unwrap(); + let host = DNSNameRef::try_from_ascii_str(stream.host()) + .expect("rustls currently only handles hostname-based connections. See https://github.com/briansmith/webpki/issues/54"); ConnectAsyncExt { fut: TlsConnector::from(self.connector.clone()).connect(host, io), stream: Some(stream), diff --git a/actix-connect/tests/test_connect.rs b/actix-connect/tests/test_connect.rs index a8fdb1b6..471dd314 100644 --- a/actix-connect/tests/test_connect.rs +++ b/actix-connect/tests/test_connect.rs @@ -42,6 +42,7 @@ fn test_rustls_string() { let con = test::call_service(&mut conn, addr.into()); assert_eq!(con.peer_addr().unwrap(), srv.addr()); } + #[test] fn test_static_str() { let srv = TestServer::with(|| {