mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 19:49:19 +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>
41 lines
862 B
JavaScript
41 lines
862 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
|
|
var https = require('https');
|
|
var fs = require('fs');
|
|
|
|
var options = {
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
|
|
ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem')
|
|
};
|
|
|
|
|
|
var server = https.Server(options, function(req, res) {
|
|
res.writeHead(200);
|
|
res.end('hello world\n');
|
|
});
|
|
|
|
|
|
server.listen(0, function() {
|
|
https.get({
|
|
path: '/',
|
|
port: this.address().port,
|
|
rejectUnauthorized: true,
|
|
servername: 'agent1',
|
|
ca: options.ca
|
|
}, function(res) {
|
|
res.resume();
|
|
console.log(res.statusCode);
|
|
server.close();
|
|
}).on('error', function(e) {
|
|
console.log(e.message);
|
|
process.exit(1);
|
|
});
|
|
});
|