File tree Expand file tree Collapse file tree
packages/pg-connection-string Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
@@ -133,6 +135,9 @@ function parse(str, options = {}) {
133135 case 'require' :
134136 case 'verify-ca' :
135137 case 'verify-full' : {
138+ if ( config . sslmode !== 'verify-full' ) {
139+ deprecatedSslModeWarning ( config . sslmode )
140+ }
136141 break
137142 }
138143 case 'no-verify' : {
@@ -201,6 +206,20 @@ function parseIntoClientConfig(str) {
201206 return toClientConfig ( parse ( str ) )
202207}
203208
209+ function deprecatedSslModeWarning ( sslmode ) {
210+ if ( ! deprecatedSslModeWarning . warned ) {
211+ deprecatedSslModeWarning . warned = true
212+ emitWarning ( `SECURITY WARNING: The SSL modes 'prefer', 'require', and 'verify-ca' are treated as aliases for 'verify-full'.
213+ In the next major version (v3.0.0), these modes will adopt standard libpq semantics, which have weaker security guarantees.
214+
215+ To prepare for this change:
216+ - If you want the current behavior, explicitly use 'sslmode=verify-full'
217+ - If you want libpq compatibility now, use 'uselibpqcompat=true&sslmode=${ sslmode } '
218+
219+ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode definitions.` )
220+ }
221+ }
222+
204223module . exports = parse
205224
206225parse . parse = parse
You can’t perform that action at this time.
0 commit comments