2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2016-12-01 09:49:13 -06:00
|
|
|
const common = require('../common');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-03-04 12:11:21 +11:00
|
|
|
}
|
2016-12-01 09:49:13 -06:00
|
|
|
const tls = require('tls');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2016-12-01 09:49:13 -06:00
|
|
|
const net = require('net');
|
|
|
|
const fs = require('fs');
|
2012-12-03 18:29:01 +01:00
|
|
|
|
2016-12-01 09:49:13 -06:00
|
|
|
const options = {
|
2012-12-03 18:29:01 +01:00
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
|
|
|
|
handshakeTimeout: 50
|
|
|
|
};
|
|
|
|
|
2017-02-03 14:54:19 -05:00
|
|
|
const server = tls.createServer(options, common.mustNotCall());
|
2012-12-03 18:29:01 +01:00
|
|
|
|
2016-07-15 15:43:24 -04:00
|
|
|
server.on('tlsClientError', common.mustCall(function(err, conn) {
|
2012-12-03 18:29:01 +01:00
|
|
|
conn.destroy();
|
|
|
|
server.close();
|
2016-07-15 15:43:24 -04:00
|
|
|
}));
|
2012-12-03 18:29:01 +01:00
|
|
|
|
2016-12-01 09:49:13 -06:00
|
|
|
server.listen(0, common.mustCall(function() {
|
2016-05-29 03:06:56 -04:00
|
|
|
net.connect({ host: '127.0.0.1', port: this.address().port });
|
2016-12-01 09:49:13 -06:00
|
|
|
}));
|