tls: null not valid as a renegotiate callback

Allow undefined as a callback, but do not allow null.

PR-URL: https://github.com/nodejs/node/pull/25929
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Sam Roberts 2019-02-04 10:13:18 -08:00 committed by Anna Henningsen
parent 6da82b1057
commit 00d49ad673
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
2 changed files with 7 additions and 1 deletions

View File

@ -601,7 +601,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)

View File

@ -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) => {