Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: make tls test more rigorous #18792

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}));
}));