Skip to content

Commit

Permalink
Remove double-send of ssl request packet (#2086)
Browse files Browse the repository at this point in the history
* 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](#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.
  • Loading branch information
brianc committed Jan 30, 2020
1 parent c0df3b3 commit 5be3d95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,3 +8,4 @@ package-lock.json
dist
.DS_Store
.vscode/
manually-test-on-heroku.js
10 changes: 0 additions & 10 deletions packages/pg/lib/connection.js
Expand Up @@ -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')
})
}
Expand Down
15 changes: 15 additions & 0 deletions 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()
})

0 comments on commit 5be3d95

Please sign in to comment.