aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2018-06-26 10:19:35 +0200
committerPeter Eisentraut <peter_e@gmx.net>2018-07-30 13:46:27 +0200
commit98efa76fe313f62f84b94cd1f46c913c221b41fe (patch)
tree692e3bbe61f94b7798339a956c73f845a3c18707
parentab87b8fedce3fa77ca0d684a42ecc055f189eb33 (diff)
downloadpostgresql-98efa76fe313f62f84b94cd1f46c913c221b41fe.tar.gz
postgresql-98efa76fe313f62f84b94cd1f46c913c221b41fe.zip
Add ssl_library preset parameter
This allows querying the SSL implementation used on the server side. It's analogous to using PQsslAttribute(conn, "library") in libpq. Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
-rw-r--r--doc/src/sgml/config.sgml16
-rw-r--r--src/backend/libpq/be-secure.c1
-rw-r--r--src/backend/utils/misc/guc.c15
-rw-r--r--src/include/libpq/libpq.h1
-rw-r--r--src/test/ssl/t/001_ssltests.pl7
5 files changed, 39 insertions, 1 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 4d48d93305a..bee4afbe4e7 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -8401,6 +8401,22 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
</listitem>
</varlistentry>
+ <varlistentry id="guc-ssl-library" xreflabel="ssl_library">
+ <term><varname>ssl_library</varname> (<type>string</type>)
+ <indexterm>
+ <primary><varname>ssl_library</varname> configuration parameter</primary>
+ </indexterm>
+ </term>
+ <listitem>
+ <para>
+ Reports the name of the SSL library that this PostgreSQL server was
+ built with (even if SSL is not currently configured or in use on this
+ instance), for example <literal>OpenSSL</literal>, or an empty string
+ if none.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-wal-block-size" xreflabel="wal_block_size">
<term><varname>wal_block_size</varname> (<type>integer</type>)
<indexterm>
diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c
index edfe2c0751c..d349d7c2c72 100644
--- a/src/backend/libpq/be-secure.c
+++ b/src/backend/libpq/be-secure.c
@@ -38,6 +38,7 @@
#include "storage/proc.h"
+char *ssl_library;
char *ssl_cert_file;
char *ssl_key_file;
char *ssl_ca_file;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index c123de1a59e..c5ba149996e 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -3724,6 +3724,21 @@ static struct config_string ConfigureNamesString[] =
},
{
+ {"ssl_library", PGC_INTERNAL, PRESET_OPTIONS,
+ gettext_noop("Name of the SSL library."),
+ NULL,
+ GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
+ },
+ &ssl_library,
+#ifdef USE_SSL
+ "OpenSSL",
+#else
+ "",
+#endif
+ NULL, NULL, NULL
+ },
+
+ {
{"ssl_cert_file", PGC_SIGHUP, CONN_AUTH_SSL,
gettext_noop("Location of the SSL server certificate file."),
NULL
diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h
index 7bf06c65e96..36baf6b9199 100644
--- a/src/include/libpq/libpq.h
+++ b/src/include/libpq/libpq.h
@@ -75,6 +75,7 @@ extern int pq_putbytes(const char *s, size_t len);
/*
* prototypes for functions in be-secure.c
*/
+extern char *ssl_library;
extern char *ssl_cert_file;
extern char *ssl_key_file;
extern char *ssl_ca_file;
diff --git a/src/test/ssl/t/001_ssltests.pl b/src/test/ssl/t/001_ssltests.pl
index e550207454d..2b875a3c956 100644
--- a/src/test/ssl/t/001_ssltests.pl
+++ b/src/test/ssl/t/001_ssltests.pl
@@ -8,7 +8,7 @@ use File::Copy;
if ($ENV{with_openssl} eq 'yes')
{
- plan tests => 64;
+ plan tests => 65;
}
else
{
@@ -49,6 +49,11 @@ $node->init;
$ENV{PGHOST} = $node->host;
$ENV{PGPORT} = $node->port;
$node->start;
+
+# Run this before we lock down access below.
+my $result = $node->safe_psql('postgres', "SHOW ssl_library");
+is($result, 'OpenSSL', 'ssl_library parameter');
+
configure_test_server_for_ssl($node, $SERVERHOSTADDR, 'trust');
note "testing password-protected keys";