Skip to content

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: https://github.com/nodejs/node/issues/49839

Before

node:internal/assert:14
    throw new ERR_INTERNAL_ASSERTION(message);
    ^

Error [ERR_INTERNAL_ASSERTION]: This is caused by either a bug in Node.js or incorrect usage of Node.js internals.
Please open an issue with this stack trace at https://github.com/nodejs/node/issues

After

node:internal/validators:440
    throw new ERR_INVALID_ARG_TYPE(name, 'Function', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "options.checkServerIdentity" property must be of type function. Received undefined

Merge request reports

Loading