Skip to content

Commit 706ad8f

Browse files
davidbenrvagg
authored andcommitted
crypto: remove locking callbacks for OpenSSL 1.1.0
The callbacks are all no-ops in OpenSSL 1.1.0. This isn't necessary (the functions still exist for compatibility), but silences some warnings and avoids allocating a few unused mutexes. PR-URL: nodejs#16130 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent afee2ed commit 706ad8f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/node_crypto.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,6 @@ static X509_NAME *cnnic_ev_name =
227227
d2i_X509_NAME(nullptr, &cnnic_ev_p,
228228
sizeof(CNNIC_EV_ROOT_CA_SUBJECT_DATA)-1);
229229

230-
static Mutex* mutexes;
231-
232230
static const char* const root_certs[] = {
233231
#include "node_root_certs.h" // NOLINT(build/include_order)
234232
};
@@ -297,6 +295,9 @@ template int SSLWrap<TLSWrap>::SelectALPNCallback(
297295
void* arg);
298296
#endif // TLSEXT_TYPE_application_layer_protocol_negotiation
299297

298+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
299+
static Mutex* mutexes;
300+
300301
static void crypto_threadid_cb(CRYPTO_THREADID* tid) {
301302
static_assert(sizeof(uv_thread_t) <= sizeof(void*),
302303
"uv_thread_t does not fit in a pointer");
@@ -319,6 +320,7 @@ static void crypto_lock_cb(int mode, int n, const char* file, int line) {
319320
else
320321
mutex->Unlock();
321322
}
323+
#endif
322324

323325

324326
static int PasswordCallback(char *buf, int size, int rwflag, void *u) {
@@ -5976,9 +5978,11 @@ void InitCryptoOnce() {
59765978
SSL_library_init();
59775979
OpenSSL_add_all_algorithms();
59785980

5981+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
59795982
crypto_lock_init();
59805983
CRYPTO_set_locking_callback(crypto_lock_cb);
59815984
CRYPTO_THREADID_set_callback(crypto_threadid_cb);
5985+
#endif
59825986

59835987
#ifdef NODE_FIPS_MODE
59845988
/* Override FIPS settings in cnf file, if needed. */

0 commit comments

Comments
 (0)