-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: implement capture rejections for 'secureConnection' event
PR-URL: #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>
- Loading branch information
1 parent
75972da
commit ba18406
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'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()); | ||
})); |