node-postgres

node-postgres supports TLS/SSL connections to your PostgreSQL server as long as the server is configured to support it. When instantiating a pool or a client you can provide an property on the config object and it will be passed to the constructor for the node TLSSocket.

Self-signed cert

Here’s an example of a configuration you can use to connect a client or a pool to a PostgreSQL server.

Usage with

If you plan to use a combination of a database connection string from the environment and SSL settings in the config object directly, then you must avoid including any of , , , or in the connection string. If any of these options are used then the object is replaced and any additional options provided there will be lost.

Channel binding

If the PostgreSQL server offers SCRAM-SHA-256-PLUS (i.e. channel binding) for TLS/SSL connections, you can enable this as follows:

or

Data TypesNative