diff options
author | Daniel Gustafsson <dgustafsson@postgresql.org> | 2022-03-29 14:02:45 +0200 |
---|---|---|
committer | Daniel Gustafsson <dgustafsson@postgresql.org> | 2022-03-29 14:02:45 +0200 |
commit | ebc8b7d4416d8e0dfb7c05132ef6182fd3daf885 (patch) | |
tree | 04d15606691eb1773d9b7915fb66998ce5d6ce07 /src/interfaces/libpq/t | |
parent | 8cd7627c7b19c5a1bb235e7ad91b53856b101e65 (diff) | |
download | postgresql-ebc8b7d4416d8e0dfb7c05132ef6182fd3daf885.tar.gz |
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 <pchampion@vmware.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/4c8b76ef434a96627170a31c3acd33cbfd6e41f1.camel@vmware.com
Diffstat (limited to 'src/interfaces/libpq/t')
-rw-r--r-- | src/interfaces/libpq/t/002_api.pl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/interfaces/libpq/t/002_api.pl b/src/interfaces/libpq/t/002_api.pl new file mode 100644 index 0000000000..7c6c5788a0 --- /dev/null +++ b/src/interfaces/libpq/t/002_api.pl @@ -0,0 +1,20 @@ +# Copyright (c) 2022, PostgreSQL Global Development Group +use strict; +use warnings; + +use PostgreSQL::Test::Utils; +use Test::More; + +# Test PQsslAttribute(NULL, "library") +my ($out, $err) = run_command(['testclient', '--ssl']); + +if ($ENV{with_ssl} eq 'openssl') +{ + is($out, 'OpenSSL', 'PQsslAttribute(NULL, "library") returns "OpenSSL"'); +} +else +{ + is($err, 'SSL is not enabled', 'PQsslAttribute(NULL, "library") returns NULL'); +} + +done_testing(); |