Skip to content

Commit

Permalink
Solve issues caused by config.ssl = true
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie authored and brianc committed Oct 4, 2020
1 parent 6be3b90 commit 9cbea21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions packages/pg-connection-string/index.js
Expand Up @@ -65,7 +65,7 @@ function parse(str) {
config.ssl = false
}

if (config.sslcert || config.sslkey || config.sslrootcert) {
if (config.sslcert || config.sslkey || config.sslrootcert || config.sslmode) {
config.ssl = {}
}

Expand All @@ -90,11 +90,9 @@ function parse(str) {
case 'require':
case 'verify-ca':
case 'verify-full': {
config.ssl = config.ssl || true
break
}
case 'no-verify': {
config.ssl = config.ssl || {}
config.ssl.rejectUnauthorized = false
break
}
Expand Down
8 changes: 4 additions & 4 deletions packages/pg-connection-string/test/parse.js
Expand Up @@ -258,25 +258,25 @@ describe('parse', function () {
it('configuration parameter sslmode=prefer', function () {
var connectionString = 'pg:///?sslmode=prefer'
var subject = parse(connectionString)
subject.ssl.should.eql(true)
subject.ssl.should.eql({})
})

it('configuration parameter sslmode=require', function () {
var connectionString = 'pg:///?sslmode=require'
var subject = parse(connectionString)
subject.ssl.should.eql(true)
subject.ssl.should.eql({})
})

it('configuration parameter sslmode=verify-ca', function () {
var connectionString = 'pg:///?sslmode=verify-ca'
var subject = parse(connectionString)
subject.ssl.should.eql(true)
subject.ssl.should.eql({})
})

it('configuration parameter sslmode=verify-full', function () {
var connectionString = 'pg:///?sslmode=verify-full'
var subject = parse(connectionString)
subject.ssl.should.eql(true)
subject.ssl.should.eql({})
})

it("configuration parameter sslmode=require doesn't overwrite sslrootcert=/path/to/ca", function () {
Expand Down

0 comments on commit 9cbea21

Please sign in to comment.