postgresql/src
Heikki Linnakangas 17a834a04d Reject SSL connection if ALPN is used but there's no common protocol
If the client supports ALPN but tries to use some other protocol, like
HTTPS, reject the connection in the server. That is surely a confusion
of some sort. Furthermore, the ALPN RFC 7301 says:

> In the event that the server supports no protocols that the client
> advertises, then the server SHALL respond with a fatal
> "no_application_protocol" alert.

This commit makes the server follow that advice.

In the client, specifically check for the OpenSSL error code for the
"no_application_protocol" alert. Otherwise you got a cryptic "SSL
error: SSL error code 167773280" error if you tried to connect to a
non-PostgreSQL server that rejects the connection with
"no_application_protocol". ERR_reason_error_string() returns NULL for
that code, which frankly seems like an OpenSSL bug to me, but we can
easily print a better message ourselves.

Reported-by: Jacob Champion
Discussion: https://www.postgresql.org/message-id/6aedcaa5-60f3-49af-a857-2c76ba55a1f3@iki.fi
2024-04-29 18:12:26 +03:00
..
backend Reject SSL connection if ALPN is used but there's no common protocol 2024-04-29 18:12:26 +03:00
bin libpq: If ALPN is not used, make PQsslAttribute(conn, "alpn") == "" 2024-04-29 12:26:46 +03:00
common Remove redundant JSON parser typedefs 2024-04-27 07:02:57 -04:00
fe_utils Allow dbname to be written as part of connstring via pg_basebackup's -R option. 2024-03-21 10:50:33 +05:30
include Revert "Add GUC backtrace_on_internal_error" 2024-04-29 10:49:42 +02:00
interfaces Reject SSL connection if ALPN is used but there's no common protocol 2024-04-29 18:12:26 +03:00
makefiles Optimize pg_popcount() with AVX-512 instructions. 2024-04-06 21:56:23 -05:00
pl Fix plpgsql's handling of -- comments following expressions. 2024-04-10 15:45:58 -04:00
port Fix code for probing availability of AVX-512. 2024-04-23 10:54:04 -05:00
template
test Make two-phase tests of ECPG and main suite more concurrent-proof 2024-04-29 21:10:41 +09:00
timezone
tools Remove redundant JSON parser typedefs 2024-04-27 07:02:57 -04:00
tutorial
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Update Unicode data to CLDR 45 2024-04-22 09:16:33 +02:00
Makefile.shlib
meson.build
nls-global.mk