mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

This helps to prevent issues where a failed test can keep a bound socket open long enough to cause other tests to fail with EADDRINUSE because the same port number is used. PR-URL: https://github.com/nodejs/node/pull/7045 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
36 lines
981 B
JavaScript
36 lines
981 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
var tls = require('tls');
|
|
|
|
var assert = require('assert');
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
|
|
var key = fs.readFileSync(path.join(common.fixturesDir, '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({
|
|
key: key,
|
|
cert: cert
|
|
}).listen(0, function() {
|
|
var 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() {
|
|
assert(socket.authorized);
|
|
process.exit();
|
|
});
|
|
});
|