postgresql/src/interfaces/libpq
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
..
po Update copyright for 2024 2024-01-03 20:49:05 -05:00
t Document PG_TEST_EXTRA=libpq_encryption and also check 'kerberos' 2024-04-12 19:52:39 +03:00
test Update copyright for 2024 2024-01-03 20:49:05 -05:00
.gitignore Run tap tests in src/interfaces/libpq. 2022-02-26 16:51:47 -08:00
Makefile Move libpq encryption negotiation tests 2024-04-12 19:52:37 +03:00
README Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
exports.txt Support retrieval of results in chunks with libpq. 2024-04-06 20:45:11 -04:00
fe-auth-sasl.h Refactor SASL exchange to return tri-state status 2024-03-21 14:45:46 +01:00
fe-auth-scram.c Refactor SASL exchange to return tri-state status 2024-03-21 14:45:46 +01:00
fe-auth.c Explicitly require password for SCRAM exchange 2024-03-21 14:45:54 +01:00
fe-auth.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-cancel.c Fix typos and duplicate words 2024-04-18 21:28:07 +02:00
fe-connect.c libpq: Fix error messages when server rejects SSL or GSS 2024-04-29 18:12:21 +03:00
fe-exec.c Support retrieval of results in chunks with libpq. 2024-04-06 20:45:11 -04:00
fe-gssapi-common.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-gssapi-common.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-lobj.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-misc.c Expose PQsocketPoll via libpq 2024-04-02 10:15:56 -04:00
fe-print.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-protocol3.c Support retrieval of results in chunks with libpq. 2024-04-06 20:45:11 -04:00
fe-secure-common.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-secure-common.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-secure-gssapi.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-secure-openssl.c Reject SSL connection if ALPN is used but there's no common protocol 2024-04-29 18:12:26 +03:00
fe-secure.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
fe-trace.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
legacy-pqsignal.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
libpq-events.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
libpq-events.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
libpq-fe.h Support TLS handshake directly without SSLRequest negotiation 2024-04-08 04:24:49 +03:00
libpq-int.h Support TLS handshake directly without SSLRequest negotiation 2024-04-08 04:24:49 +03:00
meson.build Move libpq encryption negotiation tests 2024-04-12 19:52:37 +03:00
nls.mk Add missing source file to libpq/nls.mk 2024-04-17 09:11:02 +02:00
pg_service.conf.sample Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
pqexpbuffer.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
pqexpbuffer.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
pthread-win32.c Clean up Windows-specific mutex code in libpq and ecpglib. 2024-02-09 11:11:39 -05:00
win32.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
win32.h Recognize network-failure errnos as indicating hard connection loss. 2020-10-10 13:28:12 -04:00

README

src/interfaces/libpq/README

This directory contains the C version of Libpq, the POSTGRES frontend library.