diff options
author | Daniel Gustafsson | 2022-03-29 12:02:45 +0000 |
---|---|---|
committer | Daniel Gustafsson | 2022-03-29 12:02:45 +0000 |
commit | ebc8b7d4416d8e0dfb7c05132ef6182fd3daf885 (patch) | |
tree | 04d15606691eb1773d9b7915fb66998ce5d6ce07 /src/interfaces/libpq/fe-secure-openssl.c | |
parent | 8cd7627c7b19c5a1bb235e7ad91b53856b101e65 (diff) |
Enable SSL library detection via PQsslAttribute()
Currently, libpq client code must have a connection handle
before it can query the "library" SSL attribute. This poses
problems if the client needs to know what SSL library is in
use before constructing a connection string.
Allow PQsslAttribute(NULL, "library") to return the library
in use -- currently, just "OpenSSL" or NULL. The new behavior
is announced with the LIBPQ_HAS_SSL_LIBRARY_DETECTION feature
macro, allowing clients to differentiate between a libpq that
was compiled without SSL support and a libpq that's just too
old to tell.
Author: Jacob Champion <[email protected]>
Reviewed-by: Robert Haas <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: https://postgr.es/m/[email protected]
Diffstat (limited to 'src/interfaces/libpq/fe-secure-openssl.c')
-rw-r--r-- | src/interfaces/libpq/fe-secure-openssl.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index d81218a4ccd..d3bf57b850a 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -1631,14 +1631,14 @@ PQsslAttributeNames(PGconn *conn) const char * PQsslAttribute(PGconn *conn, const char *attribute_name) { + if (strcmp(attribute_name, "library") == 0) + return "OpenSSL"; + if (!conn) return NULL; if (conn->ssl == NULL) return NULL; - if (strcmp(attribute_name, "library") == 0) - return "OpenSSL"; - if (strcmp(attribute_name, "key_bits") == 0) { static char sslbits_str[12]; |