Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c8fb1e9

Browse files
authored
feat(pg-connection-string): warn if non-standard ssl options are used (#3473)
* feat(pg-connection-string): warn if non-standard ssl options are used In preparation for v3.0.0, we start warning users to be explicit about the sslmode they want. * Update index.js
1 parent 54e0424 commit c8fb1e9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎packages/pg-connection-string/index.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict'
22

3+
const { emitWarning } = require('node:process')
4+
35
//Parse method copied from https://github.com/brianc/node-postgres
46
//Copyright (c) 2010-2014 Brian Carlson (brian.m.carlson@gmail.com)
57
//MIT License
@@ -138,6 +140,9 @@ function parse(str, options = {}) {
138140
case 'require':
139141
case 'verify-ca':
140142
case 'verify-full': {
143+
if (config.sslmode !== 'verify-full') {
144+
deprecatedSslModeWarning(config.sslmode)
145+
}
141146
break
142147
}
143148
case 'no-verify': {
@@ -206,6 +211,20 @@ function parseIntoClientConfig(str) {
206211
return toClientConfig(parse(str))
207212
}
208213

214+
function deprecatedSslModeWarning(sslmode) {
215+
if (!deprecatedSslModeWarning.warned) {
216+
deprecatedSslModeWarning.warned = true
217+
emitWarning(`SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
218+
In the next major version (pg-connection-string v3.0.0 and pg v9.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees.
219+
220+
To prepare for this change:
221+
- If you want the current behavior, explicitly use 'sslmode=verify-full'
222+
- If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${sslmode}'
223+
224+
See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.`)
225+
}
226+
}
227+
209228
module.exports = parse
210229

211230
parse.parse = parse

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /