From 379b5f79a9e974668e632f8cf461a16e6d4e7ba9 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 2 Jun 2021 11:10:50 +0200 Subject: [PATCH] tls: tweak clientCertEngine argument parsing PR-URL: https://github.com/nodejs/node/pull/38900 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- lib/internal/tls.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/internal/tls.js b/lib/internal/tls.js index 0ebecb57c88779..0a9eea8f3eb026 100644 --- a/lib/internal/tls.js +++ b/lib/internal/tls.js @@ -305,15 +305,15 @@ function configSecureContext(context, options = {}, name = 'options') { } } - if (clientCertEngine !== undefined) { + if (typeof clientCertEngine === 'string') { if (typeof context.setClientCertEngine !== 'function') throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED(); - if (typeof clientCertEngine !== 'string') { - throw new ERR_INVALID_ARG_TYPE(`${name}.clientCertEngine`, - ['string', 'null', 'undefined'], - clientCertEngine); - } - context.setClientCertEngine(clientCertEngine); + else + context.setClientCertEngine(clientCertEngine); + } else if (clientCertEngine !== undefined) { + throw new ERR_INVALID_ARG_TYPE(`${name}.clientCertEngine`, + ['string', 'null', 'undefined'], + clientCertEngine); } if (ticketKeys !== undefined) {