Skip to content

Commit f055a66

Browse files
indutnyrvagg
authored andcommitted
crypto: enable FIPS only when configured with it
Do not rely on `OPENSSL_FIPS` in `node_crypto.cc` when building with shared FIPS-enabled OpenSSL library. Enable FIPS in core only when configured with `--openssl-fips`. Fix: #3077 PR-URL: #3153 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 0858c86 commit f055a66

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

node.gyp

+3
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@
228228
'src/tls_wrap.h'
229229
],
230230
'conditions': [
231+
['openssl_fips != ""', {
232+
'defines': [ 'NODE_FIPS_MODE' ],
233+
}],
231234
[ 'node_shared_openssl=="false"', {
232235
'dependencies': [
233236
'./deps/openssl/openssl.gyp:openssl',

src/node_crypto.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -5323,13 +5323,13 @@ void InitCryptoOnce() {
53235323
CRYPTO_set_locking_callback(crypto_lock_cb);
53245324
CRYPTO_THREADID_set_callback(crypto_threadid_cb);
53255325

5326-
#ifdef OPENSSL_FIPS
5326+
#ifdef NODE_FIPS_MODE
53275327
if (!FIPS_mode_set(1)) {
53285328
int err = ERR_get_error();
53295329
fprintf(stderr, "openssl fips failed: %s\n", ERR_error_string(err, NULL));
53305330
UNREACHABLE();
53315331
}
5332-
#endif // OPENSSL_FIPS
5332+
#endif // NODE_FIPS_MODE
53335333

53345334

53355335
// Turn off compression. Saves memory and protects against CRIME attacks.

0 commit comments

Comments
 (0)