diff --git a/src/client.rs b/src/client.rs index 3f6ba13f..8ad0d47b 100644 --- a/src/client.rs +++ b/src/client.rs @@ -348,7 +348,15 @@ pub async fn startup_tls( ) -> Result>, WriteHalf>>, Error> { // Negotiate TLS. let tls = Tls::new()?; - let addr = stream.peer_addr().unwrap(); + let addr = match stream.peer_addr() { + Ok(addr) => addr, + Err(err) => { + return Err(Error::SocketError(format!( + "Failed to get peer address: {:?}", + err + ))); + } + }; let mut stream = match tls.acceptor.accept(stream).await { Ok(stream) => stream,