11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciif (!common.hasCrypto) 51cb0ef41Sopenharmony_ci common.skip('missing crypto'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst assert = require('assert'); 81cb0ef41Sopenharmony_ciconst events = require('events'); 91cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures'); 101cb0ef41Sopenharmony_ciconst { createServer, connect } = require('tls'); 111cb0ef41Sopenharmony_ciconst cert = fixtures.readKey('rsa_cert.crt'); 121cb0ef41Sopenharmony_ciconst key = fixtures.readKey('rsa_private.pem'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cievents.captureRejections = true; 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciconst server = createServer({ cert, key }, common.mustCall(async (sock) => { 171cb0ef41Sopenharmony_ci server.close(); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci const _err = new Error('kaboom'); 201cb0ef41Sopenharmony_ci sock.on('error', common.mustCall((err) => { 211cb0ef41Sopenharmony_ci assert.strictEqual(err, _err); 221cb0ef41Sopenharmony_ci })); 231cb0ef41Sopenharmony_ci throw _err; 241cb0ef41Sopenharmony_ci})); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 271cb0ef41Sopenharmony_ci const sock = connect({ 281cb0ef41Sopenharmony_ci port: server.address().port, 291cb0ef41Sopenharmony_ci host: server.address().host, 301cb0ef41Sopenharmony_ci rejectUnauthorized: false 311cb0ef41Sopenharmony_ci }); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci sock.on('close', common.mustCall()); 341cb0ef41Sopenharmony_ci})); 35