2015-06-09 00:25:06 +02:00
|
|
|
'use strict';
|
|
|
|
var common = require('../common');
|
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
2016-05-11 21:34:52 +02:00
|
|
|
common.skip('missing crypto');
|
2015-07-07 17:25:55 +02:00
|
|
|
return;
|
2015-06-09 00:25:06 +02:00
|
|
|
}
|
|
|
|
var tls = require('tls');
|
|
|
|
var fs = require('fs');
|
|
|
|
var net = require('net');
|
|
|
|
|
2016-01-26 00:00:06 +01:00
|
|
|
var bonkers = Buffer.alloc(1024, 42);
|
2015-06-09 00:25:06 +02:00
|
|
|
|
|
|
|
var options = {
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
|
|
};
|
|
|
|
|
2016-07-15 21:43:24 +02:00
|
|
|
var server = net.createServer(common.mustCall(function(c) {
|
|
|
|
setTimeout(common.mustCall(function() {
|
2015-06-09 00:25:06 +02:00
|
|
|
var s = new tls.TLSSocket(c, {
|
|
|
|
isServer: true,
|
|
|
|
secureContext: tls.createSecureContext(options)
|
|
|
|
});
|
|
|
|
|
2016-07-15 21:43:24 +02:00
|
|
|
s.on('_tlsError', common.mustCall(function() {}));
|
2015-06-09 00:25:06 +02:00
|
|
|
|
|
|
|
s.on('close', function() {
|
|
|
|
server.close();
|
|
|
|
s.destroy();
|
|
|
|
});
|
2016-07-15 21:43:24 +02:00
|
|
|
}), 200);
|
|
|
|
})).listen(0, function() {
|
2016-05-29 09:06:56 +02:00
|
|
|
var c = net.connect({port: this.address().port}, function() {
|
2015-06-09 00:25:06 +02:00
|
|
|
c.write(bonkers);
|
|
|
|
});
|
|
|
|
});
|