Skip to content
Permalink
Browse files

tls: null not valid as a renegotiate callback

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

PR-URL: #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>
  • Loading branch information...
sam-github authored and addaleax committed Feb 4, 2019
1 parent 6da82b1 commit 00d49ad673b0c4851298ef00522af60186210cfd
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/_tls_wrap.js
  2. +6 −0 test/parallel/test-tls-disable-renegotiation.js
@@ -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)
@@ -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) => {

0 comments on commit 00d49ad

Please sign in to comment.
You can’t perform that action at this time.