From 2f48c90ddb48a58f8a780fae1b58d8f0c4c5766f Mon Sep 17 00:00:00 2001 From: Charlie Hornsby Date: Thu, 6 May 2021 10:55:20 +0300 Subject: [PATCH] Warn about mixed use of connectionString and ssl --- content/features/6-ssl.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/content/features/6-ssl.mdx b/content/features/6-ssl.mdx index 4d1aeea..0428d05 100644 --- a/content/features/6-ssl.mdx +++ b/content/features/6-ssl.mdx @@ -44,3 +44,18 @@ pool .catch(err => console.error('error connecting', err.stack)) .then(() => pool.end()) ``` + +## Usage with `connectionString` + +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 `sslcert`, `sslkey`, `sslrootcert`, or `sslmode` in the connection string. If any of these options are used then the `ssl` object is replaced and any additional options provided there will be lost. + +```js +const config = { + connectionString: 'postgres://user:password@host:port/db?sslmode=require', + // Beware! The ssl object is overwritten when parsing the connectionString + ssl: { + rejectUnauthorized: false, + ca: fs.readFileSync('/path/to/server-certificates/root.crt').toString(), + }, +} +```