Skip to content

Commit 5be3d95

Browse files
authored
Remove double-send of ssl request packet (brianc#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](brianc#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.
1 parent c0df3b3 commit 5be3d95

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ package-lock.json
88
dist
99
.DS_Store
1010
.vscode/
11+
manually-test-on-heroku.js

Diff for: packages/pg/lib/connection.js

-10
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,7 @@ Connection.prototype.connect = function (port, host) {
115115
}
116116
self.stream = tls.connect(options)
117117
self.stream.on('error', reportStreamError)
118-
119-
// send SSLRequest packet
120-
const buff = Buffer.alloc(8)
121-
buff.writeUInt32BE(8)
122-
buff.writeUInt32BE(80877103, 4)
123-
if (self.stream.writable) {
124-
self.stream.write(buff)
125-
}
126-
127118
self.attachListeners(self.stream)
128-
129119
self.emit('sslconnect')
130120
})
131121
}

Diff for: packages/pg/test/integration/gh-issues/2085-tests.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
"use strict"
4+
var helper = require('./../test-helper')
5+
var assert = require('assert')
6+
7+
const suite = new helper.Suite()
8+
9+
suite.testAsync('it should connect over ssl', async () => {
10+
const client = new helper.pg.Client({ ssl: 'require'})
11+
await client.connect()
12+
const { rows } = await client.query('SELECT NOW()')
13+
assert.strictEqual(rows.length, 1)
14+
await client.end()
15+
})

0 commit comments

Comments
 (0)