From: cosgroveb (@cosgroveb) <noreply+cosgroveb@github.com>
To: pgbouncer/pgbouncer <noreply+pgbouncer-pgbouncer@github.com>
Subject: Re: [pgbouncer/pgbouncer] PR #1584: feat: add support for upstream TLSDirect
Date: Tue, 29 Sep 2026 13:17:24 +0000
Message-ID: <gh-pgbouncer-pgbouncer-1584-rc4133898630@github.com> (raw)
In-Reply-To: <gh-pgbouncer-pgbouncer-1584@github.com>
References: <gh-pgbouncer-pgbouncer-1584@github.com>
(on lib/usual/tls/tls_client.c:196)
`tls_handshake_client()` accepts connections without checking the server's ALPN selection. PostgreSQL [requires ALPN for direct TLS](https://www.postgresql.org/docs/17/protocol-flow.html#PROTOCOL-FLOW-SSL) to prevent protocol confusion.
For direct TLS, check the selection after the handshake, just like [libpq does](https://github.com/postgres/postgres/blob/REL_17_0/src/interfaces/libpq/fe-secure-openssl.c#L1496-L1...). Reject a missing selection or a protocol other than `postgresql` before PgBouncer sends StartupMessage. We should also add a test that asserts rejection before StartupMessage when the TLS endpoint doesn't select an ALPN protocol.