Skip to content

Commit

Permalink
Add SNI and peer address on handshake error logs
Browse files Browse the repository at this point in the history
Signed-off-by: Eloi DEMOLIS <[email protected]>
  • Loading branch information
Wonshtrum committed Nov 28, 2023
1 parent 757a6f1 commit b455bbf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/src/https.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl HttpsSession {
sock,
token,
request_id,
peer_address,
))
};

Expand Down Expand Up @@ -232,6 +233,7 @@ impl HttpsSession {
frontend,
self.frontend_token,
request_id,
self.peer_address,
);
handshake.frontend_readiness.event = readiness.event;
// Can we remove this? If not why?
Expand Down
33 changes: 28 additions & 5 deletions lib/src/protocol/rustls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{cell::RefCell, io::ErrorKind, rc::Rc};
use std::{cell::RefCell, io::ErrorKind, net::SocketAddr, rc::Rc};

use mio::{net::TcpStream, Token};
use rustls::ServerConnection;
Expand All @@ -21,6 +21,7 @@ pub struct TlsHandshake {
pub container_frontend_timeout: TimeoutContainer,
pub frontend_readiness: Readiness,
frontend_token: Token,
pub peer_address: Option<SocketAddr>,
pub request_id: Ulid,
pub session: ServerConnection,
pub stream: TcpStream,
Expand All @@ -37,6 +38,7 @@ impl TlsHandshake {
stream: TcpStream,
frontend_token: Token,
request_id: Ulid,
peer_address: Option<SocketAddr>,
) -> TlsHandshake {
TlsHandshake {
container_frontend_timeout,
Expand All @@ -45,6 +47,7 @@ impl TlsHandshake {
event: Ready::EMPTY,
},
frontend_token,
peer_address,
request_id,
session,
stream,
Expand Down Expand Up @@ -72,14 +75,24 @@ impl TlsHandshake {
can_read = false
}
_ => {
error!("could not perform handshake: {:?}", e);
error!(
"Session(sni={:?}, source={:?}) could not perform handshake: {:?}",
self.session.server_name(),
self.peer_address,
e
);
return SessionResult::Close;
}
},
}

if let Err(e) = self.session.process_new_packets() {
error!("could not perform handshake: {:?}", e);
error!(
"Session(sni={:?}, source={:?}) could not perform handshake: {:?}",
self.session.server_name(),
self.peer_address,
e
);
return SessionResult::Close;
}
}
Expand Down Expand Up @@ -129,14 +142,24 @@ impl TlsHandshake {
can_write = false
}
_ => {
error!("could not perform handshake: {:?}", e);
error!(
"Session(sni={:?}, source={:?}) could not perform handshake: {:?}",
self.session.server_name(),
self.peer_address,
e
);
return SessionResult::Close;
}
},
}

if let Err(e) = self.session.process_new_packets() {
error!("could not perform handshake: {:?}", e);
error!(
"Session(sni={:?}, source={:?}) could not perform handshake: {:?}",
self.session.server_name(),
self.peer_address,
e
);
return SessionResult::Close;
}
}
Expand Down

0 comments on commit b455bbf

Please sign in to comment.