2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-31 00:38:06 +01:00
|
|
|
const common = require('../common');
|
2015-03-09 21:00:24 +01:00
|
|
|
|
2017-07-01 01:29:09 +02:00
|
|
|
if (!common.hasCrypto)
|
2016-05-11 21:34:52 +02:00
|
|
|
common.skip('missing crypto');
|
2015-03-09 21:00:24 +01:00
|
|
|
|
2016-12-31 00:38:06 +01:00
|
|
|
const https = require('https');
|
2017-10-06 20:55:39 +02:00
|
|
|
const fixtures = require('../common/fixtures');
|
2015-03-09 21:00:24 +01:00
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
const options = {
|
2017-10-06 20:55:39 +02:00
|
|
|
key: fixtures.readKey('agent1-key.pem'),
|
|
|
|
cert: fixtures.readKey('agent1-cert.pem'),
|
|
|
|
ca: fixtures.readKey('ca1-cert.pem')
|
2015-03-09 21:00:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2017-01-08 14:19:00 +01:00
|
|
|
const server = https.Server(options, function(req, res) {
|
2015-03-09 21:00:24 +01:00
|
|
|
res.writeHead(200);
|
|
|
|
res.end('hello world\n');
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-05-29 09:06:56 +02:00
|
|
|
server.listen(0, function() {
|
2015-03-09 21:00:24 +01:00
|
|
|
https.get({
|
|
|
|
path: '/',
|
2016-05-29 09:06:56 +02:00
|
|
|
port: this.address().port,
|
2015-03-09 21:00:24 +01:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|