mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 07:27:32 +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>
43 lines
869 B
JavaScript
43 lines
869 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
var tls = require('tls');
|
|
|
|
var fs = require('fs');
|
|
|
|
var options = {
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'),
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem')
|
|
};
|
|
|
|
var cert = null;
|
|
|
|
var server = tls.createServer(options, function(conn) {
|
|
conn.end('ok');
|
|
}).listen(0, function() {
|
|
var c = tls.connect(this.address().port, {
|
|
rejectUnauthorized: false
|
|
}, function() {
|
|
c.on('end', common.mustCall(function() {
|
|
c.end();
|
|
server.close();
|
|
}));
|
|
|
|
c.on('data', function(data) {
|
|
assert.equal(data, 'ok');
|
|
});
|
|
|
|
cert = c.getPeerCertificate();
|
|
});
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert(cert);
|
|
assert.equal(cert.subject.C, 'US');
|
|
});
|