From b426892a3630e02cca77813df213d524b8c97e3b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 29 Nov 2020 10:03:21 -0800 Subject: [PATCH] tls: permit null as a cipher value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow null along with undefined for cipher value. Fixes: https://github.com/nodejs/node/issues/36292 PR-URL: https://github.com/nodejs/node/pull/36318 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Tobias Nießen --- lib/_tls_common.js | 2 +- test/parallel/test-tls-set-ciphers.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/_tls_common.js b/lib/_tls_common.js index ef40ea2591e879..b1d28b9c49aad4 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -263,7 +263,7 @@ exports.createSecureContext = function createSecureContext(options) { } } - if (ciphers !== undefined) + if (ciphers != null) validateString(ciphers, 'options.ciphers'); // Work around an OpenSSL API quirk. cipherList is for TLSv1.2 and below, diff --git a/test/parallel/test-tls-set-ciphers.js b/test/parallel/test-tls-set-ciphers.js index 57bd2f8652a3e0..f08af9b089adb9 100644 --- a/test/parallel/test-tls-set-ciphers.js +++ b/test/parallel/test-tls-set-ciphers.js @@ -104,3 +104,7 @@ test('AES256-SHA', ':', U, U, 'ERR_INVALID_ARG_VALUE'); // Using '' is synonymous for "use default ciphers" test('TLS_AES_256_GCM_SHA384', '', 'TLS_AES_256_GCM_SHA384'); test('', 'TLS_AES_256_GCM_SHA384', 'TLS_AES_256_GCM_SHA384'); + +// Using null should be treated the same as undefined. +test(null, 'AES256-SHA', 'AES256-SHA'); +test('AES256-SHA', null, 'AES256-SHA');