-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept `new net.Socket()` as a `socket` option to `tls.connect()` without triggering an assertion error in C++. This is done by wrapping it into a JSStream to ensure that there will be a handle at the time of wrapping the socket into TLSSocket. Fix: #987 PR-URL: #1046 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
- Loading branch information
Showing
2 changed files
with
60 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
if (!process.versions.openssl) { | ||
console.error('Skipping because node compiled without OpenSSL.'); | ||
process.exit(0); | ||
} | ||
|
||
var assert = require('assert'); | ||
var fs = require('fs'); | ||
var net = require('net'); | ||
var tls = require('tls'); | ||
|
||
var common = require('../common'); | ||
|
||
var out = ''; | ||
|
||
var server = tls.createServer({ | ||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), | ||
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') | ||
}, function(c) { | ||
c.end('hello'); | ||
}).listen(common.PORT, function() { | ||
var socket = new net.Socket(); | ||
|
||
var s = tls.connect({ | ||
socket: socket, | ||
rejectUnauthorized: false | ||
}, function() { | ||
s.on('data', function(chunk) { | ||
out += chunk; | ||
}); | ||
s.on('end', function() { | ||
s.destroy(); | ||
server.close(); | ||
}); | ||
}); | ||
|
||
socket.connect(common.PORT); | ||
}); | ||
|
||
process.on('exit', function() { | ||
assert.equal(out, 'hello'); | ||
}); |