mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
Get rid of deprecated OpenSSL <1.1 functions
This commit is contained in:
@@ -30,8 +30,6 @@ extern "C" {
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#include <QtNetwork/QSslSocket>
|
||||
|
||||
uint64 _SharedMemoryLocation[4] = { 0x00, 0x01, 0x02, 0x03 };
|
||||
|
||||
// Base types compile-time check
|
||||
@@ -56,15 +54,6 @@ static_assert(sizeof(int) >= 4, "Basic types size check failed");
|
||||
|
||||
// Precise timing functions / rand init
|
||||
|
||||
struct CRYPTO_dynlock_value {
|
||||
QMutex mutex;
|
||||
};
|
||||
|
||||
namespace {
|
||||
bool _sslInited = false;
|
||||
QMutex *_sslLocks = nullptr;
|
||||
}
|
||||
|
||||
namespace ThirdParty {
|
||||
|
||||
void start() {
|
||||
@@ -94,45 +83,11 @@ namespace ThirdParty {
|
||||
LOG(("MTP Error: Could not init OpenSSL rand, RAND_status() is 0..."));
|
||||
}
|
||||
}
|
||||
|
||||
// Force OpenSSL loading if it is linked in Qt,
|
||||
// so that we won't mess with our OpenSSL locking with Qt OpenSSL locking.
|
||||
auto sslSupported = QSslSocket::supportsSsl();
|
||||
if (!sslSupported) {
|
||||
LOG(("Error: current Qt build doesn't support SSL requests."));
|
||||
}
|
||||
if (!CRYPTO_get_locking_callback()) {
|
||||
// Qt didn't initialize OpenSSL, so we will.
|
||||
auto numLocks = CRYPTO_num_locks();
|
||||
if (numLocks) {
|
||||
_sslLocks = new QMutex[numLocks];
|
||||
CRYPTO_set_locking_callback(_sslLockingCallback);
|
||||
} else {
|
||||
LOG(("MTP Error: Could not init OpenSSL threads, CRYPTO_num_locks() returned zero!"));
|
||||
}
|
||||
}
|
||||
if (!CRYPTO_get_dynlock_create_callback()) {
|
||||
CRYPTO_set_dynlock_create_callback(_sslCreateFunction);
|
||||
CRYPTO_set_dynlock_lock_callback(_sslLockFunction);
|
||||
CRYPTO_set_dynlock_destroy_callback(_sslDestroyFunction);
|
||||
} else if (!CRYPTO_get_dynlock_lock_callback()) {
|
||||
LOG(("MTP Error: dynlock_create callback is set without dynlock_lock callback!"));
|
||||
}
|
||||
|
||||
_sslInited = true;
|
||||
}
|
||||
|
||||
void finish() {
|
||||
CRYPTO_cleanup_all_ex_data();
|
||||
#ifndef LIBRESSL_VERSION_NUMBER
|
||||
FIPS_mode_set(0);
|
||||
#endif
|
||||
ENGINE_cleanup();
|
||||
CONF_modules_unload(1);
|
||||
ERR_free_strings();
|
||||
EVP_cleanup();
|
||||
|
||||
delete[] base::take(_sslLocks);
|
||||
|
||||
Platform::ThirdParty::finish();
|
||||
}
|
||||
|
Reference in New Issue
Block a user