Skip to content

Commit

Permalink
test: make tls test more rigorous
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
bnoordhuis authored and BridgeAR committed Feb 16, 2018
1 parent 85893af commit 3c29adb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/parallel/test-tls-connect-no-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ if (!common.hasCrypto)
common.skip('missing crypto');

const tls = require('tls');

const assert = require('assert');

const cert = fixtures.readSync('test_cert.pem');
Expand All @@ -15,19 +14,20 @@ const key = fixtures.readSync('test_key.pem');
// https://github.com/nodejs/node/issues/1489
// tls.connect(options) with no options.host should accept a cert with
// CN:'localhost'
tls.createServer({
const server = tls.createServer({
key,
cert
}).listen(0, function() {
}).listen(0, common.mustCall(function() {
const socket = tls.connect({
port: this.address().port,
ca: cert,
// No host set here. 'localhost' is the default,
// but tls.checkServerIdentity() breaks before the fix with:
// Error: Hostname/IP doesn't match certificate's altnames:
// "Host: undefined. is not cert's CN: localhost"
}, function() {
}, common.mustCall(function() {
assert(socket.authorized);
process.exit();
});
});
socket.destroy();
server.close();
}));
}));

0 comments on commit 3c29adb

Please sign in to comment.