Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b956635

Browse filesBrowse files
indutnyMyles Borins
authored andcommitted
tls: catch certCbDone exceptions
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>
1 parent 53a67ed commit b956635
Copy full SHA for b956635

File tree

Expand file treeCollapse file tree

2 files changed

+47
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+47
-1
lines changed
Open diff view settings
Collapse file

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,11 @@ function oncertcb(info) {
184184
if (!self._handle)
185185
return self.destroy(new Error('Socket is closed'));
186186

187-
self._handle.certCbDone();
187+
try {
188+
self._handle.certCbDone();
189+
} catch (e) {
190+
self.destroy(e);
191+
}
188192
});
189193
});
190194
}
Collapse file
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'use strict';
2+
3+
if (!process.features.tls_sni) {
4+
console.log('1..0 # Skipped: node compiled without OpenSSL or ' +
5+
'with old OpenSSL version.');
6+
return;
7+
}
8+
9+
const common = require('../common');
10+
const assert = require('assert');
11+
12+
if (!common.hasCrypto) {
13+
console.log('1..0 # Skipped: missing crypto');
14+
return;
15+
}
16+
17+
const tls = require('tls');
18+
19+
const options = {
20+
SNICallback: (name, callback) => {
21+
callback(null, tls.createSecureContext());
22+
}
23+
};
24+
25+
const server = tls.createServer(options, (c) => {
26+
common.fail('Should not be called');
27+
}).on('clientError', common.mustCall((err, c) => {
28+
assert(/SSL_use_certificate:passed a null parameter/i.test(err.message));
29+
server.close();
30+
})).listen(common.PORT, common.mustCall(() => {
31+
const c = tls.connect({
32+
port: common.PORT,
33+
rejectUnauthorized: false,
34+
servername: 'any.name'
35+
}, () => {
36+
common.fail('Should not be called');
37+
});
38+
39+
c.on('error', common.mustCall((err) => {
40+
assert(/socket hang up/.test(err.message));
41+
}));
42+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.