Skip to content

Commit e210798

Browse files
davidbengibfahn
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: #16130 Backport-PR-URL: #18622 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Rod Vagg <[email protected]>
1 parent c2106e4 commit e210798

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
@@ -235,8 +235,6 @@ static X509_NAME *cnnic_ev_name =
235235
d2i_X509_NAME(nullptr, &cnnic_ev_p,
236236
sizeof(CNNIC_EV_ROOT_CA_SUBJECT_DATA)-1);
237237

238-
static Mutex* mutexes;
239-
240238
static const char* const root_certs[] = {
241239
#include "node_root_certs.h" // NOLINT(build/include_order)
242240
};
@@ -303,6 +301,9 @@ template int SSLWrap<TLSWrap>::SelectALPNCallback(
303301
void* arg);
304302
#endif // TLSEXT_TYPE_application_layer_protocol_negotiation
305303

304+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
305+
static Mutex* mutexes;
306+
306307
static void crypto_threadid_cb(CRYPTO_THREADID* tid) {
307308
static_assert(sizeof(uv_thread_t) <= sizeof(void*),
308309
"uv_thread_t does not fit in a pointer");
@@ -325,6 +326,7 @@ static void crypto_lock_cb(int mode, int n, const char* file, int line) {
325326
else
326327
mutex->Unlock();
327328
}
329+
#endif
328330

329331

330332
static int PasswordCallback(char *buf, int size, int rwflag, void *u) {
@@ -6162,9 +6164,11 @@ void InitCryptoOnce() {
61626164
SSL_library_init();
61636165
OpenSSL_add_all_algorithms();
61646166

6167+
#if OPENSSL_VERSION_NUMBER < 0x10100000L
61656168
crypto_lock_init();
61666169
CRYPTO_set_locking_callback(crypto_lock_cb);
61676170
CRYPTO_THREADID_set_callback(crypto_threadid_cb);
6171+
#endif
61686172

61696173
#ifdef NODE_FIPS_MODE
61706174
/* Override FIPS settings in cnf file, if needed. */

0 commit comments

Comments
 (0)