diff --git a/src/crypto/crypto_util.cc b/src/crypto/crypto_util.cc index fc0d57f36e9840..674428eeefd6cc 100644 --- a/src/crypto/crypto_util.cc +++ b/src/crypto/crypto_util.cc @@ -120,7 +120,8 @@ bool ProcessFipsOptions() { return EVP_default_properties_enable_fips(nullptr, 1) && EVP_default_properties_is_fips_enabled(nullptr); #else - return FIPS_mode() == 0 && FIPS_mode_set(1); + if (FIPS_mode() == 0) return FIPS_mode_set(1); + #endif } return true; diff --git a/test/parallel/test-crypto-fips.js b/test/parallel/test-crypto-fips.js index 964d5dbb4054f4..8a8a8089a3cf3b 100644 --- a/test/parallel/test-crypto-fips.js +++ b/test/parallel/test-crypto-fips.js @@ -77,13 +77,17 @@ testHelper( 'process.versions', process.env); -// By default FIPS should be off in both FIPS and non-FIPS builds. -testHelper( - 'stdout', - [], - FIPS_DISABLED, - 'require("crypto").getFips()', - { ...process.env, 'OPENSSL_CONF': ' ' }); +// By default FIPS should be off in both FIPS and non-FIPS builds +// unless Node.js was configured using --shared-openssl in +// which case it may be enabled by the system. +if (!sharedOpenSSL()) { + testHelper( + 'stdout', + [], + FIPS_DISABLED, + 'require("crypto").getFips()', + { ...process.env, 'OPENSSL_CONF': ' ' }); +} // Toggling fips with setFips should not be allowed from a worker thread testHelper(