From 5be3d95f624e70153a8516f44bfb38b9be706ddf Mon Sep 17 00:00:00 2001 From: Brian C Date: Wed, 29 Jan 2020 18:10:23 -0600 Subject: [PATCH] Remove double-send of ssl request packet (#2086) * Remove double-send of ssl request packet I missed the fact that we are already sending this. Since I don't have good test coverage for ssl [which I am planning on fixing next](https://github.com/brianc/node-postgres/issues/2009) this got missed. I'm forcing an SSL test on travis. This will break for me locally as I don't have SSL enabled on my local test DB. Something I will also remedy. --- .gitignore | 1 + packages/pg/lib/connection.js | 10 ---------- .../pg/test/integration/gh-issues/2085-tests.js | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 packages/pg/test/integration/gh-issues/2085-tests.js diff --git a/.gitignore b/.gitignore index bae2a20a..b6e058f2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ package-lock.json dist .DS_Store .vscode/ +manually-test-on-heroku.js diff --git a/packages/pg/lib/connection.js b/packages/pg/lib/connection.js index 6fa0696c..a63d9cde 100644 --- a/packages/pg/lib/connection.js +++ b/packages/pg/lib/connection.js @@ -115,17 +115,7 @@ Connection.prototype.connect = function (port, host) { } self.stream = tls.connect(options) self.stream.on('error', reportStreamError) - - // send SSLRequest packet - const buff = Buffer.alloc(8) - buff.writeUInt32BE(8) - buff.writeUInt32BE(80877103, 4) - if (self.stream.writable) { - self.stream.write(buff) - } - self.attachListeners(self.stream) - self.emit('sslconnect') }) } diff --git a/packages/pg/test/integration/gh-issues/2085-tests.js b/packages/pg/test/integration/gh-issues/2085-tests.js new file mode 100644 index 00000000..36f30c74 --- /dev/null +++ b/packages/pg/test/integration/gh-issues/2085-tests.js @@ -0,0 +1,15 @@ + + +"use strict" +var helper = require('./../test-helper') +var assert = require('assert') + +const suite = new helper.Suite() + +suite.testAsync('it should connect over ssl', async () => { + const client = new helper.pg.Client({ ssl: 'require'}) + await client.connect() + const { rows } = await client.query('SELECT NOW()') + assert.strictEqual(rows.length, 1) + await client.end() +})