GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tls: use `validateFunction` for `options.SNICallback` · nodejs/node@d905c61

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • _tls_wrap.js
  • test/parallel
    • test-tls-snicallback-error.js
Expand file treeCollapse file tree
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
@@ -909,7 +909,7 @@ TLSSocket.prototype._init = function(socket, wrap) {
909909
options.SNICallback &&
910910
(options.SNICallback !== SNICallback ||
911911
(options.server && options.server._contexts.length))) {
912-
assert(typeof options.SNICallback === 'function');
912+
validateFunction(options.SNICallback, 'options.SNICallback');
913913
this._SNICallback = options.SNICallback;
914914
ssl.enableCertCb();
915915
}
Collapse file

‎test/parallel/test-tls-snicallback-error.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-snicallback-error.js
+16-6Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ if (!common.hasCrypto)
44
common.skip('missing crypto');
55

66
const assert = require('assert');
7+
const net = require('net');
78
const tls = require('tls');
89

9-
['fhqwhgads', 42, {}, []].forEach((testValue) => {
10-
assert.throws(
11-
() => { tls.createServer({ SNICallback: testValue }); },
12-
{ code: 'ERR_INVALID_ARG_TYPE', message: /\boptions\.SNICallback\b/ }
13-
);
14-
});
10+
for (const SNICallback of ['fhqwhgads', 42, {}, []]) {
11+
assert.throws(() => {
12+
tls.createServer({ SNICallback });
13+
}, {
14+
code: 'ERR_INVALID_ARG_TYPE',
15+
name: 'TypeError',
16+
});
17+
18+
assert.throws(() => {
19+
new tls.TLSSocket(new net.Socket(), { isServer: true, SNICallback });
20+
}, {
21+
code: 'ERR_INVALID_ARG_TYPE',
22+
name: 'TypeError',
23+
});
24+
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.