diff --git a/lib/client.js b/lib/client.js index d37b0a58..9fd9f513 100644 --- a/lib/client.js +++ b/lib/client.js @@ -23,14 +23,14 @@ var Client = function(config) { this.connection = c.connection || new Connection({ stream: c.stream, - ssl: c.ssl + ssl: this.connectionParameters.ssl }); this.queryQueue = []; this.binary = c.binary || defaults.binary; this.encoding = 'utf8'; this.processID = null; this.secretKey = null; - this.ssl = c.ssl || false; + this.ssl = this.connectionParameters.ssl || false; }; util.inherits(Client, EventEmitter); diff --git a/test/unit/connection-parameters/creation-tests.js b/test/unit/connection-parameters/creation-tests.js index 43420284..0624c793 100644 --- a/test/unit/connection-parameters/creation-tests.js +++ b/test/unit/connection-parameters/creation-tests.js @@ -161,4 +161,12 @@ test('libpq connection string building', function() { assert.equal(subject.ssl, true); }); + test('ssl is set on client', function() { + var Client = require('../../../lib/client') + var defaults = require('../../../lib/defaults'); + defaults.ssl = true; + var c = new Client('postgres://user@password:host/database') + assert(c.ssl, 'Client should have ssl enabled via defaults') + }) + });