summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Gustafsson <dgustafsson@postgresql.org>2021-08-13 10:32:17 +0200
committerDaniel Gustafsson <dgustafsson@postgresql.org>2021-08-13 10:32:17 +0200
commit512f4ca6c6b5d2e3a1620288048ccaa712121e12 (patch)
treebada30dccac0d30ca1cee115f55dab6de044e1fd
parent37450f2ca9ad430d78673cc26816fc2085e65904 (diff)
Fix sslsni connparam boolean check
The check for sslsni only checked for existence of the parameter but not for the actual value of the param. This meant that the SNI extension was always turned on. Fix by inspecting the value of sslsni and only activate the SNI extension iff sslsni has been enabled. Also update the docs to be more in line with how other boolean params are documented. Backpatch to 14 where sslsni was first implemented. Reviewed-by: Tom Lane Backpatch-through: 14, where sslni was added
-rw-r--r--doc/src/sgml/libpq.sgml2
-rw-r--r--src/interfaces/libpq/fe-secure-openssl.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 56689ba8730..b449c834a95 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1782,7 +1782,7 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<term><literal>sslsni</literal><indexterm><primary>Server Name Indication</primary></indexterm></term>
<listitem>
<para>
- By default, libpq sets the TLS extension <quote>Server Name
+ If set to 1 (default), libpq sets the TLS extension <quote>Server Name
Indication</quote> (<acronym>SNI</acronym>) on SSL-enabled connections.
By setting this parameter to 0, this is turned off.
</para>
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 2ee5a0a40aa..e3b43c87233 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -1092,7 +1092,7 @@ initialize_SSL(PGconn *conn)
* Per RFC 6066, do not set it if the host is a literal IP address (IPv4
* or IPv6).
*/
- if (conn->sslsni && conn->sslsni[0])
+ if (conn->sslsni && conn->sslsni[0] == '1')
{
const char *host = conn->connhost[conn->whichhost].host;