1'use strict'; 2 3const common = require('../common'); 4 5if (!common.hasCrypto) 6 common.skip('missing crypto'); 7 8const net = require('net'); 9const tls = require('tls'); 10const fixtures = require('../common/fixtures'); 11 12const key = fixtures.readKey('agent1-key.pem'); 13const cert = fixtures.readKey('agent1-cert.pem'); 14 15const secureContext = tls.createSecureContext({ key, cert }); 16 17const server = net.createServer(common.mustCall((conn) => { 18 const options = { isServer: true, secureContext, server }; 19 const socket = new tls.TLSSocket(conn, options); 20 socket.once('data', common.mustCall(() => { 21 socket._destroySSL(); // Should not crash. 22 socket.destroy(); 23 server.close(); 24 })); 25})); 26 27server.listen(0, function() { 28 const options = { 29 port: this.address().port, 30 rejectUnauthorized: false, 31 }; 32 tls.connect(options, function() { 33 this.write('*'.repeat(1 << 20)); // Write more data than fits in a frame. 34 this.on('error', this.destroy); // Server closes connection on us. 35 }); 36}); 37