mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 08:22:59 +01:00
simplify HttpServer::start_tls() method
This commit is contained in:
parent
e3081306da
commit
856055c6ca
@ -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"))]
|
||||
|
@ -333,21 +333,12 @@ impl<H: IntoHttpHandler> HttpServer<H>
|
||||
impl<H: IntoHttpHandler> HttpServer<H>
|
||||
{
|
||||
/// Start listening for incoming tls connections.
|
||||
pub fn start_tls(mut self, pkcs12: ::Pkcs12) -> io::Result<SyncAddress<Self>> {
|
||||
pub fn start_tls(mut self, acceptor: TlsAcceptor) -> io::Result<SyncAddress<Self>> {
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user