2017-03-17 14:31:14 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
|
2017-06-30 23:29:09 +00:00
|
|
|
if (!common.hasCrypto)
|
2017-03-17 14:31:14 +00:00
|
|
|
common.skip('missing crypto');
|
|
|
|
|
|
|
|
const net = require('net');
|
|
|
|
const tls = require('tls');
|
2017-07-17 22:33:46 +00:00
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
|
|
|
|
const key = fixtures.readKey('agent1-key.pem');
|
|
|
|
const cert = fixtures.readKey('agent1-cert.pem');
|
2017-03-17 14:31:14 +00:00
|
|
|
|
|
|
|
const secureContext = tls.createSecureContext({ key, cert });
|
|
|
|
|
|
|
|
const server = net.createServer(common.mustCall((conn) => {
|
|
|
|
const options = { isServer: true, secureContext, server };
|
|
|
|
const socket = new tls.TLSSocket(conn, options);
|
|
|
|
socket.once('data', common.mustCall(() => {
|
|
|
|
socket._destroySSL(); // Should not crash.
|
2018-01-08 00:14:06 +00:00
|
|
|
socket.destroy();
|
2017-03-17 14:31:14 +00:00
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
|
|
|
|
server.listen(0, function() {
|
|
|
|
const options = {
|
|
|
|
port: this.address().port,
|
|
|
|
rejectUnauthorized: false,
|
|
|
|
};
|
|
|
|
tls.connect(options, function() {
|
|
|
|
this.write('*'.repeat(1 << 20)); // Write more data than fits in a frame.
|
|
|
|
this.on('error', this.destroy); // Server closes connection on us.
|
|
|
|
});
|
|
|
|
});
|