diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index d918656a360c7a..887db012e78402 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -974,7 +974,7 @@ exports.connect = function(/* [port, host], options, cb */) { assert(typeof options.minDHSize === 'number', 'options.minDHSize is not a number: ' + options.minDHSize); assert(options.minDHSize > 0, - 'options.minDHSize is not a posivie number: ' + + 'options.minDHSize is not a positive number: ' + options.minDHSize); var hostname = options.servername || diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js index a497fdd9f2de62..a67a3cd67d983b 100644 --- a/test/parallel/test-tls-client-mindhsize.js +++ b/test/parallel/test-tls-client-mindhsize.js @@ -78,6 +78,15 @@ testDHE1024(); assert.throws(() => test(512, true, assert.fail), /DH parameter is less than 1024 bits/); +[0, -1, -Infinity, NaN].forEach(minDHSize => { + assert.throws(() => tls.connect({ minDHSize }), + /minDHSize is not a positive number/); +}); + +[true, false, null, undefined, {}, [], '', '1'].forEach(minDHSize => { + assert.throws(() => tls.connect({ minDHSize }), /minDHSize is not a number/); +}); + process.on('exit', function() { assert.equal(nsuccess, 1); assert.equal(nerror, 1);