X Tutup
The Wayback Machine - https://web.archive.org/web/20250425174404/https://github.com/nodejs/node/commit/46f94f9111
Skip to content

Commit 46f94f9

Browse files
Trottaddaleax
authored andcommitted
test: make test-tls-reuse-host-from-socket pass without internet
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>
1 parent 0695e24 commit 46f94f9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

test/internet/test-tls-reuse-host-from-socket.js renamed to test/parallel/test-tls-reuse-host-from-socket.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ const common = require('../common');
2525
if (!common.hasCrypto)
2626
common.skip('missing crypto');
2727

28-
const tls = require('tls');
29-
3028
const net = require('net');
29+
const tls = require('tls');
30+
const fixtures = require('../common/fixtures');
3131

32-
const socket = net.connect(443, 'www.example.org', common.mustCall(() => {
33-
const secureSocket = tls.connect({ socket }, common.mustCall(() => {
34-
secureSocket.destroy();
35-
console.log('ok');
32+
const server = tls.createServer({
33+
key: fixtures.readKey('agent1-key.pem'),
34+
cert: fixtures.readKey('agent1-cert.pem')
35+
}).listen(0, common.mustCall(() => {
36+
const socket = net.connect(server.address().port, common.mustCall(() => {
37+
const opts = { socket, rejectUnauthorized: false };
38+
const secureSocket = tls.connect(opts, common.mustCall(() => {
39+
secureSocket.destroy();
40+
server.close();
41+
}));
3642
}));
3743
}));

0 commit comments

Comments
 (0)
X Tutup