Skip to content

Commit 7d2bdbb

Browse files
authored
tls: Fix inbound I/O when TLS detection fails (#958)
When the proxy performs inbound TLS detection, it may break TLS streams for application-terminated TLS connections. Typically, inbound TLS detection does not actually need to buffer data from the socket to determine the SNI value for a connection. However, non-proxy clients may send enough ClientHello extensions such that detection cannot be completed from a single peek of 512B. In this situation, the proxy buffers data from the socket to determine the SNI value, but it unfortunately does not preserve this buffered data as it forward the connection. This change updates the TLS detection logic to properly preserve any data buffered from the socket in forwarded connections.
1 parent fce8c4a commit 7d2bdbb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

linkerd/tls/src/server/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,14 @@ where
247247
Ok(Some(sni)) => {
248248
trace!(%sni, "Identified non-matching SNI via peek");
249249
let tls = Conditional::Some(ServerTls::Passthru { sni });
250-
return Ok((tls, EitherIo::Left(io.into())));
250+
let io = PrefixedIo::new(buf.freeze(), io);
251+
return Ok((tls, EitherIo::Left(io)));
251252
}
252253

253254
Ok(None) => {
254255
trace!("Not a matching TLS ClientHello");
255-
return Ok((NO_TLS_META, EitherIo::Left(io.into())));
256+
let io = PrefixedIo::new(buf.freeze(), io);
257+
return Ok((NO_TLS_META, EitherIo::Left(io)));
256258
}
257259

258260
Err(client_hello::Incomplete) => {

0 commit comments

Comments
 (0)