pgsql: libpq: Add sslcertmode option to control client certificates - Mailing list pgsql-committers

From Michael Paquier
Subject pgsql: libpq: Add sslcertmode option to control client certificates
Date
Msg-id E1pfZ8T-0055uH-HP@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
libpq: Add sslcertmode option to control client certificates

The sslcertmode option controls whether the server is allowed and/or
required to request a certificate from the client.  There are three
modes:
- "allow" is the default and follows the current behavior, where a
configured client certificate is sent if the server requests one
(via one of its default locations or sslcert).  With the current
implementation, will happen whenever TLS is negotiated.
- "disable" causes the client to refuse to send a client certificate
even if sslcert is configured or if a client certificate is available in
one of its default locations.
- "require" causes the client to fail if a client certificate is never
sent and the server opens a connection anyway.  This doesn't add any
additional security, since there is no guarantee that the server is
validating the certificate correctly, but it may helpful to troubleshoot
more complicated TLS setups.

sslcertmode=require requires SSL_CTX_set_cert_cb(), available since
OpenSSL 1.0.2.  Note that LibreSSL does not include it.

Using a connection parameter different than require_auth has come up as
the simplest design because certificate authentication does not rely
directly on any of the AUTH_REQ_* codes, and one may want to require a
certificate to be sent in combination of a given authentication method,
like SCRAM-SHA-256.

TAP tests are added in src/test/ssl/, some of them relying on sslinfo to
check if a certificate has been set.  These are compatible across all
the versions of OpenSSL supported on HEAD (currently down to 1.0.1).

Author: Jacob Champion
Reviewed-by: Aleksander Alekseev, Peter Eisentraut, David G. Johnston,
Michael Paquier
Discussion: https://postgr.es/m/9e5a8ccddb8355ea9fa4b75a1e3a9edc88a70cd3.camel@vmware.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/36f40ce2dc66f1a36d6a12f7a0352e1c5bf1063e

Modified Files
--------------
configure                                | 12 +++---
configure.ac                             |  5 ++-
doc/src/sgml/libpq.sgml                  | 66 ++++++++++++++++++++++++++++++++
meson.build                              |  3 +-
src/include/pg_config.h.in               |  3 ++
src/interfaces/libpq/fe-auth.c           | 19 +++++++++
src/interfaces/libpq/fe-connect.c        | 53 +++++++++++++++++++++++++
src/interfaces/libpq/fe-secure-openssl.c | 40 ++++++++++++++++++-
src/interfaces/libpq/libpq-int.h         |  3 ++
src/test/ssl/t/001_ssltests.pl           | 42 ++++++++++++++++++++
src/test/ssl/t/003_sslinfo.pl            | 24 ++++++++++++
src/tools/msvc/Solution.pm               |  9 +++++
12 files changed, 270 insertions(+), 9 deletions(-)


pgsql-committers by date:

Previous
From: Andres Freund
Date:
Subject: pgsql: meson: add install-{quiet, world} targets
Next
From: Andres Freund
Date:
Subject: pgsql: meson: docs: add texinfo target