Skip to content

Commit 749684b

Browse files
authored
Add doc for ssl rejectUnauthorized: false (#126)
Ref: #38 (comment)
1 parent c2c0bf1 commit 749684b

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,18 @@ const sql = postgres('postgres://username:password@host:port/database', {
7272
})
7373
```
7474

75-
More info for the `ssl` option can be found in the [Node.js docs for tls connect options](https://nodejs.org/dist/latest-v10.x/docs/api/tls.html#tls_new_tls_tlssocket_socket_options)
75+
Although it is [vulnerable to MITM attacks](https://security.stackexchange.com/a/229297/174913), a common configuration for the `ssl` option for some cloud providers like Heroku is to set `rejectUnauthorized` to `false` (if `NODE_ENV` is `production`):
76+
77+
```js
78+
const sql =
79+
process.env.NODE_ENV === 'production'
80+
? // "Unless you're using a Private or Shield Heroku Postgres database, Heroku Postgres does not currently support verifiable certificates"
81+
// https://help.heroku.com/3DELT3RK/why-can-t-my-third-party-utility-connect-to-heroku-postgres-with-ssl
82+
postgres({ ssl: { rejectUnauthorized: false } })
83+
: postgres();
84+
```
85+
86+
More info for the `ssl` option can be found in the [Node.js docs for tls connect options](https://nodejs.org/dist/latest-v10.x/docs/api/tls.html#tls_new_tls_tlssocket_socket_options).
7687

7788
### Environment Variables for Options
7889

0 commit comments

Comments
 (0)