diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index e041c1257890e2..07305d9c96bdd4 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -584,7 +584,7 @@ TLSSocket.prototype._init = function(socket, wrap) { TLSSocket.prototype.renegotiate = function(options, callback) { if (options === null || typeof options !== 'object') throw new ERR_INVALID_ARG_TYPE('options', 'Object', options); - if (callback != null && typeof callback !== 'function') + if (callback !== undefined && typeof callback !== 'function') throw new ERR_INVALID_CALLBACK(); if (this.destroyed) diff --git a/test/parallel/test-tls-disable-renegotiation.js b/test/parallel/test-tls-disable-renegotiation.js index 42042a21bfbedb..da492713a0742a 100644 --- a/test/parallel/test-tls-disable-renegotiation.js +++ b/test/parallel/test-tls-disable-renegotiation.js @@ -63,6 +63,12 @@ server.listen(0, common.mustCall(() => { type: TypeError, }); + common.expectsError(() => client.renegotiate({}, null), { + code: 'ERR_INVALID_CALLBACK', + type: TypeError, + }); + + // Negotiation is still permitted for this first // attempt. This should succeed. let ok = client.renegotiate(options, common.mustCall((err) => {