Support TLS handshake directly without SSLRequest negotiation
authorHeikki Linnakangas <[email protected]>
Mon, 8 Apr 2024 01:24:49 +0000 (04:24 +0300)
committerHeikki Linnakangas <[email protected]>
Mon, 8 Apr 2024 01:24:49 +0000 (04:24 +0300)
commitd39a49c1e459804831302807c724fa6512e90cf0
tree6c4c806f3e663ace026213bf719a89873fe7a7ab
parent05fd30c0e730bd5238f62d2fdfdcfaf28b16b225
Support TLS handshake directly without SSLRequest negotiation

By skipping SSLRequest, you can eliminate one round-trip when
establishing a TLS connection. It is also more friendly to generic TLS
proxies that don't understand the PostgreSQL protocol.

This is disabled by default in libpq, because the direct TLS handshake
will fail with old server versions. It can be enabled with the
sslnegotation=direct option. It will still fall back to the negotiated
TLS handshake if the server rejects the direct attempt, either because
it is an older version or the server doesn't support TLS at all, but
the fallback can be disabled with the sslnegotiation=requiredirect
option.

Author: Greg Stark, Heikki Linnakangas
Reviewed-by: Matthias van de Meent, Jacob Champion
12 files changed:
doc/src/sgml/libpq.sgml
doc/src/sgml/protocol.sgml
src/backend/libpq/be-secure.c
src/backend/libpq/pqcomm.c
src/backend/tcop/backend_startup.c
src/include/libpq/libpq-be.h
src/include/libpq/libpq.h
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-secure-openssl.c
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-int.h
src/test/libpq_encryption/t/001_negotiate_encryption.pl