pgsql: Keep current ssl_sni setting on SSL config reload failure

From: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Keep current ssl_sni setting on SSL config reload failure
Date: 2026-10-06 11:52:22
Message-ID: E1xE3iY-00000000Y08-2q2M@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Keep current ssl_sni setting on SSL config reload failure

When reloading the SSL configuration fails, the existing config is
left in place to keep the server from being inaccessible. The GUC
backing SNI, ssl_sni, was however changed. This could lead to new
connections trying to access non-existing configurations. Fix by
storing the ssl_sni setting at the time of initialization in the
hosts context and only use the stored value during the handshake.

The patch submitted by the reporter has been significantly reworked
and expanded. Additional test cases written by Rui Zhao.

Author: Anthropic OSS program
Co-authored-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Co-authored-by: Rui Zhao <zhaorui126(at)gmail(dot)com>
Reported-by: Anthropic OSS program
Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Reviewed-by: Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Reviewed-by: Rui Zhao <zhaorui126(at)gmail(dot)com>
Discussion: https://postgr.es/m/20260920211619.9c.noahmisch@microsoft.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/72ffdffd1fcc53d6f950c35fbbe1079fbf9f15f4

Modified Files
--------------
src/backend/libpq/be-secure-openssl.c | 26 +++++-
src/test/ssl/t/004_sni.pl | 157 +++++++++++++++++++++++++++++++++-
src/test/ssl/t/SSL/Server.pm | 4 +
3 files changed, 184 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-10-06 11:52:32 pgsql: Clear SSL_hosts when destroying TLS
Previous Message Etsuro Fujita 2026-10-06 09:35:20 pgsql: postgres_fdw: Fix typo in server version check in AcquireSampleR