-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch and emit `certCbDone` exceptions instead of throwing them as `uncaughtException` and crashing the whole process. Fix: #6822 PR-URL: #6887 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
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,42 @@ | ||
'use strict'; | ||
|
||
if (!process.features.tls_sni) { | ||
console.log('1..0 # Skipped: node compiled without OpenSSL or ' + | ||
'with old OpenSSL version.'); | ||
return; | ||
} | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
|
||
if (!common.hasCrypto) { | ||
console.log('1..0 # Skipped: missing crypto'); | ||
return; | ||
} | ||
|
||
const tls = require('tls'); | ||
|
||
const options = { | ||
SNICallback: (name, callback) => { | ||
callback(null, tls.createSecureContext()); | ||
} | ||
}; | ||
|
||
const server = tls.createServer(options, (c) => { | ||
common.fail('Should not be called'); | ||
}).on('clientError', common.mustCall((err, c) => { | ||
assert(/SSL_use_certificate:passed a null parameter/i.test(err.message)); | ||
server.close(); | ||
})).listen(common.PORT, common.mustCall(() => { | ||
const c = tls.connect({ | ||
port: common.PORT, | ||
rejectUnauthorized: false, | ||
servername: 'any.name' | ||
}, () => { | ||
common.fail('Should not be called'); | ||
}); | ||
|
||
c.on('error', common.mustCall((err) => { | ||
assert(/socket hang up/.test(err.message)); | ||
})); | ||
})); |