public inbox for [email protected]
help / color / mirror / Atom feedFrom: Daniel Gustafsson <[email protected]>
To: [email protected]
Subject: SSL connection check
Date: Wed, 17 Feb 2021 11:38:45 +0100
Message-ID: <[email protected]> (raw)
PgDtc_is_recovery_available use PQgetssl() to check if SSL was used for the
connection. PQgetssl() is discouraged since it is hardcoded to the OpenSSL
implementation and may fail to identify an SSL connection in case another TLS
backend is added to postgres (a few alternatives have already been discussed on
-hackers).
The attached changes to use PQsslInUse() to perform the check, and removes a
comment which seemed out of place with this (unless I totally misunderstood
it). PQsslInUse has been available since 9.5, to cope with older libpq
versions, an autoconf check is added for falling back on PQgetssl in 9.4
through to 9.2.
--
Daniel Gustafsson https://vmware.com/
Attachments:
[application/octet-stream] pqgetssl.patch (1.5K, 2-pqgetssl.patch)
download | inline diff:
From e79f22f2f76bf92ec8290fd8786f471287e03ede Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <[email protected]>
Date: Tue, 16 Feb 2021 16:01:08 +0100
Subject: [PATCH] Refactor check for SSL connection
PQgetssl has been discouraged from use since postgres 9.5 since it
will risk false negatives if postgres supports other TLS libraries
than OpenSSL. Refactor to use PQsslInUse which has been available
since 9.5 for just this purpose.
---
configure.ac | 2 ++
connection.c | 5 ++++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 8453a29..090972a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -258,6 +258,8 @@ AC_C_CONST
AC_FUNC_STRERROR_R
AC_CHECK_FUNCS(strtoul strtoll strlcat mbstowcs wcstombs mbrtoc16 c16rtomb)
+AC_CHECK_FUNCS(PQsslInUse)
+
if test "$enable_pthreads" = yes; then
AC_CHECK_FUNCS(localtime_r strtok_r pthread_mutexattr_settype)
diff --git a/connection.c b/connection.c
index 070e043..02794ff 100644
--- a/connection.c
+++ b/connection.c
@@ -3263,10 +3263,13 @@ DLL_DECLARE int PgDtc_is_recovery_available(void *self, char *reason, int rsize)
/*
* Did we use SSL client certificate, SSPI, Kerberos or similar
* authentication methods?
- * There seems no way to check it directly.
*/
doubtCert = FALSE;
+#ifdef HAVE_PQSSLINUSE
+ if (PQsslInUse(conn->pqconn))
+#else
if (PQgetssl(conn->pqconn) != NULL)
+#endif
doubtCert = TRUE;
nameSize = sizeof(loginUser);
--
2.21.1 (Apple Git-122.3)
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: SSL connection check
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox