Skip to content

Commit f58c6ff

Browse files
committed
require verify-ca to specify sslrootcert when sslmode is libpq compat
1 parent 8d56f86 commit f58c6ff

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: packages/pg-connection-string/index.js

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ function parse(str) {
108108
break
109109
}
110110
case 'verify-ca': {
111+
if (!config.ssl.ca) {
112+
throw new Error('sslmode=verify-ca requires specifying a CA with sslrootcert')
113+
}
111114
config.ssl.checkServerIdentity = function () {}
112115
break
113116
}

Diff for: packages/pg-connection-string/test/parse.js

+7
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ describe('parse', function () {
297297

298298
it('configuration parameter sslmode=verify-ca with libpq compatibility', function () {
299299
var connectionString = 'pg:///?sslmode=verify-ca&sslcompat=libpq'
300+
expect(function () {
301+
parse(connectionString)
302+
}).to.throw()
303+
})
304+
305+
it('configuration parameter sslmode=verify-ca and sslrootcert owith libpq compatibility', function () {
306+
var connectionString = 'pg:///?sslmode=verify-ca&sslcompat=libpq&sslrootcert=' + __dirname + '/example.ca'
300307
var subject = parse(connectionString)
301308
subject.ssl.should.have.property('checkServerIdentity').that.is.a('function')
302309
expect(subject.ssl.checkServerIdentity()).be.undefined

0 commit comments

Comments
 (0)