Re: Support for NSS as a libpq TLS backend

Daniel Gustafsson <daniel@yesql.se>

From: Daniel Gustafsson <daniel@yesql.se>
To: Jacob Champion <pchampion@vmware.com>
Cc: "michael@paquier.xyz" <michael@paquier.xyz>, "hlinnaka@iki.fi" <hlinnaka@iki.fi>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>, "andrew.dunstan@2ndquadrant.com" <andrew.dunstan@2ndquadrant.com>, "thomas.munro@gmail.com" <thomas.munro@gmail.com>, "andres@anarazel.de" <andres@anarazel.de>, "sfrost@snowman.net" <sfrost@snowman.net>
Date: 2021-02-01T20:49:26Z
Lists: pgsql-hackers
> On 29 Jan 2021, at 19:46, Jacob Champion <pchampion@vmware.com> wrote:

> I think the bad news is that the static approach will need support for
> ENABLE_THREAD_SAFETY.

I did some more reading today and noticed that the NSS documentation (and their
sample code for doing crypto without TLS connections) says to use NSS_NoDB_Init
to perform a read-only init which don't require a matching close call.  Now,
the docs aren't terribly clear and also seems to have gone offline from MDN,
and skimming the code isn't entirelt self-explanatory, so I may well have
missed something.  The v24 patchset posted changes to this and at least passes
tests with decent performance so it seems worth investigating.

> (It looks like the NSS implementation of pgtls_close() needs some thread
> support too?)


Storing the context in conn would probably be better?

> The good(?) news is that I don't understand why OpenSSL's
> implementation of cryptohash doesn't _also_ need the thread-safety
> code. (Shouldn't we need to call CRYPTO_set_locking_callback() et al
> before using any of its cryptohash implementation?) So maybe we can
> implement the same global setup/teardown API for OpenSSL too and not
> have to one-off it for NSS...

No idea here, wouldn't that impact pgcrypto as well in that case?

--
Daniel Gustafsson		https://vmware.com/




Commits

  1. Add tab-completion for CREATE FOREIGN TABLE.

  2. Add tap tests for the schema publications.

  3. Move Perl test modules to a better namespace

  4. Adjust configure to insist on Perl version >= 5.8.3.

  5. Simplify code related to compilation of SSL and OpenSSL

  6. Introduce --with-ssl={openssl} as a configure option

  7. Implement support for bulk inserts in postgres_fdw

  8. Fix redundant error messages in client tools

  9. doc: Apply more consistently <productname> markup for OpenSSL

  10. Check ssl_in_use flag when reporting statistics