Skip to content

Commit

Permalink
crypto: remove locking callbacks for OpenSSL 1.1.0
Browse files Browse the repository at this point in the history
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
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
  • Loading branch information
davidben authored and evanlucas committed Nov 13, 2017
1 parent 81760ff commit 6c3ae36
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,6 @@ static X509_NAME *cnnic_ev_name =
d2i_X509_NAME(nullptr, &cnnic_ev_p,
sizeof(CNNIC_EV_ROOT_CA_SUBJECT_DATA)-1);

static Mutex* mutexes;

static const char* const root_certs[] = {
#include "node_root_certs.h" // NOLINT(build/include_order)
};
Expand Down Expand Up @@ -304,6 +302,9 @@ template int SSLWrap<TLSWrap>::SelectALPNCallback(
void* arg);
#endif // TLSEXT_TYPE_application_layer_protocol_negotiation

#if OPENSSL_VERSION_NUMBER < 0x10100000L
static Mutex* mutexes;

static void crypto_threadid_cb(CRYPTO_THREADID* tid) {
static_assert(sizeof(uv_thread_t) <= sizeof(void*),
"uv_thread_t does not fit in a pointer");
Expand All @@ -326,6 +327,7 @@ static void crypto_lock_cb(int mode, int n, const char* file, int line) {
else
mutex->Unlock();
}
#endif


static int PasswordCallback(char *buf, int size, int rwflag, void *u) {
Expand Down Expand Up @@ -6007,9 +6009,11 @@ void InitCryptoOnce() {
SSL_library_init();
OpenSSL_add_all_algorithms();

#if OPENSSL_VERSION_NUMBER < 0x10100000L
crypto_lock_init();
CRYPTO_set_locking_callback(crypto_lock_cb);
CRYPTO_THREADID_set_callback(crypto_threadid_cb);
#endif

#ifdef NODE_FIPS_MODE
/* Override FIPS settings in cnf file, if needed. */
Expand Down

0 comments on commit 6c3ae36

Please sign in to comment.