Skip to content

Commit

Permalink
test: make test-tls-reuse-host-from-socket pass without internet
Browse files Browse the repository at this point in the history
Start up a TLS server on localhost rather than using example.org.

PR-URL: #34953
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
Trott authored and richardlau committed Sep 1, 2020
1 parent 2407a7a commit 75d1612
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const tls = require('tls');

const net = require('net');
const tls = require('tls');
const fixtures = require('../common/fixtures');

const socket = net.connect(443, 'www.example.org', common.mustCall(() => {
const secureSocket = tls.connect({ socket }, common.mustCall(() => {
secureSocket.destroy();
console.log('ok');
const server = tls.createServer({
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
}).listen(0, common.mustCall(() => {
const socket = net.connect(server.address().port, common.mustCall(() => {
const opts = { socket, rejectUnauthorized: false };
const secureSocket = tls.connect(opts, common.mustCall(() => {
secureSocket.destroy();
server.close();
}));
}));
}));

0 comments on commit 75d1612

Please sign in to comment.