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