diff options
author | Fedor Indutny <fedor@indutny.com> | 2016-05-19 20:25:05 -0400 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2016-05-25 16:07:30 -0400 |
commit | 9cac8c894eb16195578311ab98bc4169fa38a3db (patch) | |
tree | 2ad1195da3b8c0ea065a1c5402f6455f8c55b461 /test | |
parent | c9a5990a76ccb15872234948e23bdc12691c2e70 (diff) | |
download | android-node-v8-9cac8c894eb16195578311ab98bc4169fa38a3db.tar.gz android-node-v8-9cac8c894eb16195578311ab98bc4169fa38a3db.tar.bz2 android-node-v8-9cac8c894eb16195578311ab98bc4169fa38a3db.zip |
tls: catch `certCbDone` exceptions
Catch and emit `certCbDone` exceptions instead of throwing them as
`uncaughtException` and crashing the whole process.
Fix: https://github.com/nodejs/node/issues/6822
PR-URL: https://github.com/nodejs/node/pull/6887
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-tls-empty-sni-context.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/parallel/test-tls-empty-sni-context.js b/test/parallel/test-tls-empty-sni-context.js new file mode 100644 index 0000000000..a3089b9de3 --- /dev/null +++ b/test/parallel/test-tls-empty-sni-context.js @@ -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('tlsClientError', 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)); + })); +})); |