diff --git a/proxy/src/pglb/handshake.rs b/proxy/src/pglb/handshake.rs index 25a2d01b4a..df6e5ecf8b 100644 --- a/proxy/src/pglb/handshake.rs +++ b/proxy/src/pglb/handshake.rs @@ -137,7 +137,13 @@ pub(crate) async fn handshake( // check the ALPN, if exists, as required. match conn_info.alpn_protocol() { - None | Some(PG_ALPN_PROTOCOL) => {} + None => { + if direct.is_some() { + warn!("missing ALPN protocol 'postgresql'"); + return Err(HandshakeError::ProtocolViolation); + } + } + Some(PG_ALPN_PROTOCOL) => {} Some(other) => { let alpn = String::from_utf8_lossy(other); warn!(%alpn, "unexpected ALPN");