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 092fb9f

Browse filesBrowse files
authored
tls: use validateFunction for options.checkServerIdentity
If user uses invalid type for `options.checkServerIdentity` in tls.connect(), it's not internal issue of Node.js. So validateFunction() is more proper than assert(). Fixes: #49839 PR-URL: #49896 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent e6e320e commit 092fb9f
Copy full SHA for 092fb9f

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎lib/_tls_wrap.js‎

Copy file name to clipboardExpand all lines: lib/_tls_wrap.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,7 @@ exports.connect = function connect(...args) {
17381738
if (!options.keepAlive)
17391739
options.singleUse = true;
17401740

1741-
assert(typeof options.checkServerIdentity === 'function');
1741+
validateFunction(options.checkServerIdentity, 'options.checkServerIdentity');
17421742
assert(typeof options.minDHSize === 'number',
17431743
'options.minDHSize is not a number: ' + options.minDHSize);
17441744
assert(options.minDHSize > 0,
Collapse file

‎test/parallel/test-tls-basic-validations.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-basic-validations.js
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,12 @@ assert.throws(() => { tls.createSecureContext({ maxVersion: 'fhqwhgads' }); },
135135
code: 'ERR_TLS_INVALID_PROTOCOL_VERSION',
136136
name: 'TypeError'
137137
});
138+
139+
for (const checkServerIdentity of [undefined, null, 1, true]) {
140+
assert.throws(() => {
141+
tls.connect({ checkServerIdentity });
142+
}, {
143+
code: 'ERR_INVALID_ARG_TYPE',
144+
name: 'TypeError',
145+
});
146+
}

0 commit comments

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