From 856055c6cab7ede3b26c0cb4d1888bbc2a9f6475 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sat, 10 Feb 2018 11:34:54 -0800 Subject: [PATCH] simplify HttpServer::start_tls() method --- src/lib.rs | 4 ---- src/server/srv.rs | 11 +---------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index faca69ce..7a6dcd37 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -138,10 +138,6 @@ pub use server::HttpServer; // re-exports pub use http::{Method, StatusCode, Version}; -#[doc(hidden)] -#[cfg(feature="tls")] -pub use native_tls::Pkcs12; - #[cfg(feature="openssl")] pub(crate) const HAS_OPENSSL: bool = true; #[cfg(not(feature="openssl"))] diff --git a/src/server/srv.rs b/src/server/srv.rs index b8429f23..79f90774 100644 --- a/src/server/srv.rs +++ b/src/server/srv.rs @@ -333,21 +333,12 @@ impl HttpServer impl HttpServer { /// Start listening for incoming tls connections. - pub fn start_tls(mut self, pkcs12: ::Pkcs12) -> io::Result> { + pub fn start_tls(mut self, acceptor: TlsAcceptor) -> io::Result> { if self.sockets.is_empty() { Err(io::Error::new(io::ErrorKind::Other, "No socket addresses are bound")) } else { let addrs: Vec<(net::SocketAddr, net::TcpListener)> = self.sockets.drain().collect(); let settings = ServerSettings::new(Some(addrs[0].0), &self.host, false); - let acceptor = match TlsAcceptor::builder(pkcs12) { - Ok(builder) => { - match builder.build() { - Ok(acceptor) => acceptor, - Err(err) => return Err(io::Error::new(io::ErrorKind::Other, err)) - } - } - Err(err) => return Err(io::Error::new(io::ErrorKind::Other, err)) - }; let workers = self.start_workers(&settings, &StreamHandlerType::Tls(acceptor)); // start acceptors threads