aboutsummaryrefslogtreecommitdiff
path: root/src/backend/tcop/backend_startup.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-04-08 04:24:51 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2024-04-08 04:24:51 +0300
commit91044ae4baeac2e501e34164a69bd5d9c4976d21 (patch)
tree030ae118927d18f14ecb8840ec6719932b79773c /src/backend/tcop/backend_startup.c
parentd39a49c1e459804831302807c724fa6512e90cf0 (diff)
downloadpostgresql-91044ae4baeac2e501e34164a69bd5d9c4976d21.tar.gz
postgresql-91044ae4baeac2e501e34164a69bd5d9c4976d21.zip
Send ALPN in TLS handshake, require it in direct SSL connections
libpq now always tries to send ALPN. With the traditional negotiated SSL connections, the server accepts the ALPN, and refuses the connection if it's not what we expect, but connecting without ALPN is still OK. With the new direct SSL connections, ALPN is mandatory. NOTE: This uses "TBD-pgsql" as the protocol ID. We must register a proper one with IANA before the release! Author: Greg Stark, Heikki Linnakangas Reviewed-by: Matthias van de Meent, Jacob Champion
Diffstat (limited to 'src/backend/tcop/backend_startup.c')
-rw-r--r--src/backend/tcop/backend_startup.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/tcop/backend_startup.c b/src/backend/tcop/backend_startup.c
index b59df3f6603..ee73d01e16c 100644
--- a/src/backend/tcop/backend_startup.c
+++ b/src/backend/tcop/backend_startup.c
@@ -407,6 +407,14 @@ ProcessSSLStartup(Port *port)
}
Assert(port->ssl_in_use);
+ if (!port->alpn_used)
+ {
+ ereport(COMMERROR,
+ (errcode(ERRCODE_PROTOCOL_VIOLATION),
+ errmsg("received direct SSL connection request without ALPN protocol negotiation extension")));
+ goto reject;
+ }
+
if (Trace_connection_negotiation)
ereport(LOG,
(errmsg("direct SSL connection accepted")));