From ce0fcdc78e061c3f411f365f36c5f64c8cec0c12 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Mon, 4 Feb 2019 10:13:18 -0800 Subject: [PATCH] tls: null not valid as a renegotiate callback Allow undefined as a callback, but do not allow null. --- lib/_tls_wrap.js | 2 +- test/parallel/test-tls-disable-renegotiation.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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) => {