Skip to content

Commit 1674359

Browse files
committed
Respect SSL setting from connection parameters
1 parent b26a430 commit 1674359

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ var Client = function(config) {
2323

2424
this.connection = c.connection || new Connection({
2525
stream: c.stream,
26-
ssl: c.ssl
26+
ssl: this.connectionParameters.ssl
2727
});
2828
this.queryQueue = [];
2929
this.binary = c.binary || defaults.binary;
3030
this.encoding = 'utf8';
3131
this.processID = null;
3232
this.secretKey = null;
33-
this.ssl = c.ssl || false;
33+
this.ssl = this.connectionParameters.ssl || false;
3434
};
3535

3636
util.inherits(Client, EventEmitter);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,12 @@ test('libpq connection string building', function() {
161161
assert.equal(subject.ssl, true);
162162
});
163163

164+
test('ssl is set on client', function() {
165+
var Client = require('../../../lib/client')
166+
var defaults = require('../../../lib/defaults');
167+
defaults.ssl = true;
168+
var c = new Client('postgres://user@password:host/database')
169+
assert(c.ssl, 'Client should have ssl enabled via defaults')
170+
})
171+
164172
});

0 commit comments

Comments
 (0)