Skip to content

Commit f18865b

Browse files
ckcr4lyfCeres6
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: nodejs#48159 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Minwoo Jung <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent de12099 commit f18865b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/node.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,6 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args,
961961
return ret;
962962
};
963963

964-
{
965-
std::string extra_ca_certs;
966-
if (credentials::SafeGetenv("NODE_EXTRA_CA_CERTS", &extra_ca_certs))
967-
crypto::UseExtraCaCerts(extra_ca_certs);
968-
}
969964
// In the case of FIPS builds we should make sure
970965
// the random source is properly initialized first.
971966
#if OPENSSL_VERSION_MAJOR >= 3
@@ -1052,6 +1047,12 @@ InitializeOncePerProcessInternal(const std::vector<std::string>& args,
10521047
CHECK(crypto::CSPRNG(buffer, length).is_ok());
10531048
return true;
10541049
});
1050+
1051+
{
1052+
std::string extra_ca_certs;
1053+
if (credentials::SafeGetenv("NODE_EXTRA_CA_CERTS", &extra_ca_certs))
1054+
crypto::UseExtraCaCerts(extra_ca_certs);
1055+
}
10551056
#endif // HAVE_OPENSSL && !defined(OPENSSL_IS_BORINGSSL)
10561057
}
10571058

0 commit comments

Comments
 (0)