Skip to content

Commit

Permalink
Support "true" as string for ssl (#2407)
Browse files Browse the repository at this point in the history
Fixes 2406
  • Loading branch information
brianc committed Nov 11, 2020
1 parent 4d203ae commit ebe412c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/pg/lib/connection-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class ConnectionParameters {

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

if (typeof this.ssl === 'string') {
if (this.ssl === 'true') {
this.ssl = true
}
}
// support passing in ssl=no-verify via connection string
if (this.ssl === 'no-verify') {
this.ssl = { rejectUnauthorized: false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ test('libpq connection string building', function () {
})

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

test('coercing string "true" to boolean', function () {
const subject = new ConnectionParameters({ ssl: 'true' })
assert.strictEqual(subject.ssl, true)
})

test('ssl is set on client', function () {
var sourceConfig = {
user: 'brian',
Expand Down

0 comments on commit ebe412c

Please sign in to comment.