Skip to content

Commit 2d5a436

Browse files
authored
Remove sslmode from connectionString to fix the example using ssl object as a param
1 parent 1f9b386 commit 2d5a436

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: content/features/6-ssl.mdx

+14
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,24 @@ pool
4949

5050
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.
5151

52+
Here's an example in that the CA file passed as parameter won't work due to the `sslmode=require` in `connectionString`:
5253
```js
5354
const config = {
5455
connectionString: 'postgres://user:password@host:port/db?sslmode=require',
5556
// Beware! The ssl object is overwritten when parsing the connectionString
57+
// If it is a self signed certificate, probably will yield to `self signed certificate in certificate chain` error
58+
ssl: {
59+
rejectUnauthorized: false,
60+
ca: fs.readFileSync('/path/to/server-certificates/root.crt').toString(),
61+
},
62+
}
63+
```
64+
65+
But this will work:
66+
```js
67+
const config = {
68+
connectionString: 'postgres://user:password@host:port/db',
69+
// The ssl object won't be overwritten because there are no config ssl on connectionString
5670
ssl: {
5771
rejectUnauthorized: false,
5872
ca: fs.readFileSync('/path/to/server-certificates/root.crt').toString(),

0 commit comments

Comments
 (0)