summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2023-05-15 17:39:11 +0200
committerGitHub <noreply@github.com>2023-05-15 15:39:11 +0000
commit5b4c7bd78f4c6d76e5b2e8351f27a6c780540f9e (patch)
treeaea246194e53b5095fec400dd3ecfa43fbaa8b9c
parent7116bc08d7ab94f488452a37985dd584a97e97d2 (diff)
downloadnode-new-5b4c7bd78f4c6d76e5b2e8351f27a6c780540f9e.tar.gz
crypto: fix setEngine() when OPENSSL_NO_ENGINE set
When OpenSSL is configured with OPENSSL_NO_ENGINE, setEngine() currently throws an internal error because the C++ binding does not export the relevant function, which causes _setEngine() to be undefined within JS. Instead, match the behavior of tls/secure-context.js and throw the existing error code ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED when OpenSSL has been configured with OPENSSL_NO_ENGINE. PR-URL: https://github.com/nodejs/node/pull/47977 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
-rw-r--r--lib/internal/crypto/util.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/internal/crypto/util.js b/lib/internal/crypto/util.js
index 8838226c59..cf044e804a 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);
}