mirror of
https://github.com/nodejs/node.git
synced 2024-11-24 12:10:08 +01:00
ed86198997
PR-URL: https://github.com/nodejs/node/pull/27867 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
35 lines
859 B
JavaScript
35 lines
859 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const events = require('events');
|
|
const fixtures = require('../common/fixtures');
|
|
const { createServer, connect } = require('tls');
|
|
const cert = fixtures.readKey('rsa_cert.crt');
|
|
const key = fixtures.readKey('rsa_private.pem');
|
|
|
|
events.captureRejections = true;
|
|
|
|
const server = createServer({ cert, key }, common.mustCall(async (sock) => {
|
|
server.close();
|
|
|
|
const _err = new Error('kaboom');
|
|
sock.on('error', common.mustCall((err) => {
|
|
assert.strictEqual(err, _err);
|
|
}));
|
|
throw _err;
|
|
}));
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const sock = connect({
|
|
port: server.address().port,
|
|
host: server.address().host,
|
|
rejectUnauthorized: false
|
|
});
|
|
|
|
sock.on('close', common.mustCall());
|
|
}));
|