This guarantees that OpenSSL is initialized properly whenever randomness
is used, even when that randomness is invoked from global constructors.
Note that this patch uses Mutex directly, rather than CCriticalSection.
This is because the lock-detection code is not necessarily initialized
during global constructors.
Partial backport of Core PR14955
https://github.com/bitcoin/bitcoin/pull/14955/commits/16e40a8b562ad849a5f5e8b21ceb375e46038243
Depends on D4393