Suor/pg-bricks

SSL, remote host and pooling

mauritslamers opened this issue · 2 comments

I would like to use pg-bricks with a remote postgres server using a secure connection. Because of this, I also would like to use connection pooling, to prevent having a delay because of the secure connection setup.

It is far from clear however how I could achieve this, as there is no documentation on it.
Also, from reading the code of how pg-bricks wraps the pg library it looks like simply "replacing" the reference to the pg object by setting it to an instance of pg.Pool in the config would not work as the APIs seem to be too different.

When not using pooling, turning on SSL on the connection is easier than anticipated. The pg library checks environment variables, which can also be set inside the application, before creating a connection:

process.env.PGSSLMODE = "[ssl-mode]";

Where ssl-mode is one of disable, prefer, require, verify-ca or verify-full.

Suor commented

pg.connect() which I use already uses polling. You can pass config object instead of string to .configure(). It should be also possible to set ssl: true there.