fix: server crash on insecure SSL

This commit is contained in:
Ace Eldeib 2020-04-27 16:20:07 -07:00
parent 297a7df519
commit af88dfac6b
1 changed files with 6 additions and 2 deletions

View File

@ -55,8 +55,12 @@ async fn listen(listener: Async<TcpListener>, tls: Option<TlsAcceptor>) -> Resul
}
Some(tls) => {
// In case of HTTPS, establish a secure TLS connection first.
let stream = tls.accept(stream).await?;
let stream = Arc::new(Mutex::new(stream));
let stream = tls.accept(stream).await;
if let Err(e) = stream {
println!("Failed to establish secure TLS connection: {:#?}", e);
continue;
};
let stream = Arc::new(Mutex::new(stream.unwrap()));
Task::spawn(async move { async_h1::accept(&host, stream, serve).await })
}
};