Skip to content

Commit ebe412c

Browse files
authored
Support "true" as string for ssl (brianc#2407)
Fixes 2406
1 parent 4d203ae commit ebe412c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/pg/lib/connection-parameters.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ class ConnectionParameters {
8080

8181
this.ssl = typeof config.ssl === 'undefined' ? readSSLConfigFromEnvironment() : config.ssl
8282

83+
if (typeof this.ssl === 'string') {
84+
if (this.ssl === 'true') {
85+
this.ssl = true
86+
}
87+
}
8388
// support passing in ssl=no-verify via connection string
8489
if (this.ssl === 'no-verify') {
8590
this.ssl = { rejectUnauthorized: false }

packages/pg/test/unit/connection-parameters/creation-tests.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ test('libpq connection string building', function () {
257257
})
258258

259259
test('password contains < and/or > characters', function () {
260-
return false
261260
var sourceConfig = {
262261
user: 'brian',
263262
password: 'hello<ther>e',
@@ -308,6 +307,11 @@ test('libpq connection string building', function () {
308307
assert(c.ssl, 'Client should have ssl enabled via defaults')
309308
})
310309

310+
test('coercing string "true" to boolean', function () {
311+
const subject = new ConnectionParameters({ ssl: 'true' })
312+
assert.strictEqual(subject.ssl, true)
313+
})
314+
311315
test('ssl is set on client', function () {
312316
var sourceConfig = {
313317
user: 'brian',

0 commit comments

Comments
 (0)