diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js index 8838226c591785..cf044e804ad05a 100644 --- a/lib/internal/crypto/util.js +++ b/lib/internal/crypto/util.js @@ -44,6 +44,7 @@ const normalizeHashName = require('internal/crypto/hashnames'); const { hideStackFrames, codes: { + ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED, ERR_CRYPTO_ENGINE_UNKNOWN, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, @@ -105,6 +106,8 @@ function setEngine(id, flags) { if (flags === 0) flags = ENGINE_METHOD_ALL; + if (typeof _setEngine !== 'function') + throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED(); if (!_setEngine(id, flags)) throw new ERR_CRYPTO_ENGINE_UNKNOWN(id); }