Skip to content

Commit 849f5c3

Browse files
bnoordhuisMylesBorins
authored andcommitted
test: make tls test more rigorous
* exit naturally, don't use process.exit() * ensure callbacks are actually called PR-URL: #18792 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent cf10a94 commit 849f5c3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/parallel/test-tls-connect-no-host.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ if (!common.hasCrypto)
66
common.skip('missing crypto');
77

88
const tls = require('tls');
9-
109
const assert = require('assert');
1110

1211
const cert = fixtures.readSync('test_cert.pem');
@@ -15,19 +14,20 @@ const key = fixtures.readSync('test_key.pem');
1514
// https://github.com/nodejs/node/issues/1489
1615
// tls.connect(options) with no options.host should accept a cert with
1716
// CN:'localhost'
18-
tls.createServer({
17+
const server = tls.createServer({
1918
key,
2019
cert
21-
}).listen(0, function() {
20+
}).listen(0, common.mustCall(function() {
2221
const socket = tls.connect({
2322
port: this.address().port,
2423
ca: cert,
2524
// No host set here. 'localhost' is the default,
2625
// but tls.checkServerIdentity() breaks before the fix with:
2726
// Error: Hostname/IP doesn't match certificate's altnames:
2827
// "Host: undefined. is not cert's CN: localhost"
29-
}, function() {
28+
}, common.mustCall(function() {
3029
assert(socket.authorized);
31-
process.exit();
32-
});
33-
});
30+
socket.destroy();
31+
server.close();
32+
}));
33+
}));

0 commit comments

Comments
 (0)