2016-02-16 21:09:31 +01:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 21:34:52 +02:00
|
|
|
common.skip('missing crypto');
|
2016-02-16 21:09:31 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const tls = require('tls');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
|
|
};
|
|
|
|
|
|
|
|
const server = tls.createServer(options, function(s) {
|
|
|
|
s.end('hello');
|
2016-05-29 09:06:56 +02:00
|
|
|
}).listen(0, function() {
|
2016-02-16 21:09:31 +01:00
|
|
|
const opts = {
|
2016-05-29 09:06:56 +02:00
|
|
|
port: this.address().port,
|
2016-02-16 21:09:31 +01:00
|
|
|
rejectUnauthorized: false
|
|
|
|
};
|
|
|
|
|
|
|
|
server.on('connection', common.mustCall(function(socket) {
|
2016-09-17 12:32:33 +02:00
|
|
|
assert.strictEqual(socket.server, server);
|
2016-02-16 21:09:31 +01:00
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
|
|
|
|
const client = tls.connect(opts, function() {
|
|
|
|
client.end();
|
|
|
|
});
|
|
|
|
});
|