Skip to content

Commit 15c2de4

Browse files
tniessentargos
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 ad2c05b commit 15c2de4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/internal/crypto/util.js

Lines changed: 3 additions & 0 deletions
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,
@@ -105,6 +106,8 @@ function setEngine(id, flags) {
105106
if (flags === 0)
106107
flags = ENGINE_METHOD_ALL;
107108

109+
if (typeof _setEngine !== 'function')
110+
throw new ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED();
108111
if (!_setEngine(id, flags))
109112
throw new ERR_CRYPTO_ENGINE_UNKNOWN(id);
110113
}

0 commit comments

Comments
 (0)