Skip to content

Commit 5445835

Browse files
ckcr4lyfMoLow
authored andcommitted
src: check node_extra_ca_certs after openssl cfg
I recently discovered that the custom NodeJS specific OpenSSL config section in openssl.cnf would not be respected, if the environment variable `NODE_EXTRA_CA_CERTS` was set. This happens even if it contains an invalid value, i.e no actual certs are read. Someone suggested moving the checking of extra ca certs to after the OpenSSL config is read, and this seems to work. PR-URL: #48159 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
1 parent d9a68b8 commit 5445835

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/node.cc

+6-5
Original file line numberDiff line numberDiff line change
@@ -969,11 +969,6 @@ std::unique_ptr<InitializationResult> InitializeOncePerProcess(
969969
return ret;
970970
};
971971

972-
{
973-
std::string extra_ca_certs;
974-
if (credentials::SafeGetenv("NODE_EXTRA_CA_CERTS", &extra_ca_certs))
975-
crypto::UseExtraCaCerts(extra_ca_certs);
976-
}
977972
// In the case of FIPS builds we should make sure
978973
// the random source is properly initialized first.
979974
#if OPENSSL_VERSION_MAJOR >= 3
@@ -1058,6 +1053,12 @@ std::unique_ptr<InitializationResult> InitializeOncePerProcess(
10581053
CHECK(crypto::CSPRNG(buffer, length).is_ok());
10591054
return true;
10601055
});
1056+
1057+
{
1058+
std::string extra_ca_certs;
1059+
if (credentials::SafeGetenv("NODE_EXTRA_CA_CERTS", &extra_ca_certs))
1060+
crypto::UseExtraCaCerts(extra_ca_certs);
1061+
}
10611062
#endif // HAVE_OPENSSL && !defined(OPENSSL_IS_BORINGSSL)
10621063
}
10631064

0 commit comments

Comments
 (0)