11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ciif (!common.hasCrypto) 61cb0ef41Sopenharmony_ci common.skip('missing crypto'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst net = require('net'); 91cb0ef41Sopenharmony_ciconst tls = require('tls'); 101cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst key = fixtures.readKey('agent1-key.pem'); 131cb0ef41Sopenharmony_ciconst cert = fixtures.readKey('agent1-cert.pem'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst secureContext = tls.createSecureContext({ key, cert }); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciconst server = net.createServer(common.mustCall((conn) => { 181cb0ef41Sopenharmony_ci const options = { isServer: true, secureContext, server }; 191cb0ef41Sopenharmony_ci const socket = new tls.TLSSocket(conn, options); 201cb0ef41Sopenharmony_ci socket.once('data', common.mustCall(() => { 211cb0ef41Sopenharmony_ci socket._destroySSL(); // Should not crash. 221cb0ef41Sopenharmony_ci socket.destroy(); 231cb0ef41Sopenharmony_ci server.close(); 241cb0ef41Sopenharmony_ci })); 251cb0ef41Sopenharmony_ci})); 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciserver.listen(0, function() { 281cb0ef41Sopenharmony_ci const options = { 291cb0ef41Sopenharmony_ci port: this.address().port, 301cb0ef41Sopenharmony_ci rejectUnauthorized: false, 311cb0ef41Sopenharmony_ci }; 321cb0ef41Sopenharmony_ci tls.connect(options, function() { 331cb0ef41Sopenharmony_ci this.write('*'.repeat(1 << 20)); // Write more data than fits in a frame. 341cb0ef41Sopenharmony_ci this.on('error', this.destroy); // Server closes connection on us. 351cb0ef41Sopenharmony_ci }); 361cb0ef41Sopenharmony_ci}); 37