Skip to content

Commit 8cabfe7

Browse files
tniessenMoLow
authored andcommitted
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: #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>
1 parent bdca468 commit 8cabfe7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/internal/crypto/util.js

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const normalizeHashName = require('internal/crypto/hashnames');
4444
const {
4545
hideStackFrames,
4646
codes: {
47+
ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED,
4748
ERR_CRYPTO_ENGINE_UNKNOWN,
4849
ERR_INVALID_ARG_TYPE,
4950
ERR_INVALID_ARG_VALUE,
@@ -110,6 +111,8 @@ function setEngine(id, flags) {
110111
if (flags === 0)
111112
flags = ENGINE_METHOD_ALL;
112113

114+
if (typeof _setEngine !== 'function')
115+
throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
113116
if (!_setEngine(id, flags))
114117
throw new ERR_CRYPTO_ENGINE_UNKNOWN(id);
115118
}

0 commit comments

Comments
 (0)