mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-23 01:49:53 +03:00
Mayaqua: Fix compilation without deprecated OpenSSL APIs
Initialization and deinitialization are deprecated. Missing headers were added. Explicit threading is also deprecated.
This commit is contained in:
parent
fb5083be29
commit
1bd39485cf
@ -34,7 +34,9 @@
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/des.h>
|
||||
#include <openssl/aes.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/conf.h>
|
||||
#include <openssl/x509v3.h>
|
||||
@ -759,6 +761,7 @@ BUF *BigNumToBuf(const BIGNUM *bn)
|
||||
// Initialization of the lock of OpenSSL
|
||||
void OpenSSL_InitLock()
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
UINT i;
|
||||
|
||||
// Initialization of the lock object
|
||||
@ -772,11 +775,13 @@ void OpenSSL_InitLock()
|
||||
// Setting the lock function
|
||||
CRYPTO_set_locking_callback(OpenSSL_Lock);
|
||||
CRYPTO_set_id_callback(OpenSSL_Id);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Release of the lock of OpenSSL
|
||||
void OpenSSL_FreeLock()
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
UINT i;
|
||||
|
||||
for (i = 0;i < ssl_lock_num;i++)
|
||||
@ -788,11 +793,13 @@ void OpenSSL_FreeLock()
|
||||
|
||||
CRYPTO_set_locking_callback(NULL);
|
||||
CRYPTO_set_id_callback(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Lock function for OpenSSL
|
||||
void OpenSSL_Lock(int mode, int n, const char *file, int line)
|
||||
{
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
LOCK *lock = ssl_lock_obj[n];
|
||||
|
||||
if (mode & CRYPTO_LOCK)
|
||||
@ -805,6 +812,7 @@ void OpenSSL_Lock(int mode, int n, const char *file, int line)
|
||||
// Unlock
|
||||
Unlock(lock);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Return the thread ID
|
||||
@ -1604,7 +1612,7 @@ X509 *NewX509(K *pub, K *priv, X *ca, NAME *name, UINT days, X_SERIAL *serial)
|
||||
{
|
||||
X509 *x509;
|
||||
UINT64 notBefore, notAfter;
|
||||
ASN1_TIME *t1, *t2;
|
||||
const ASN1_TIME *t1, *t2;
|
||||
X509_NAME *subject_name, *issuer_name;
|
||||
X509_EXTENSION *ex = NULL;
|
||||
X509_EXTENSION *eku = NULL;
|
||||
@ -1638,8 +1646,8 @@ X509 *NewX509(K *pub, K *priv, X *ca, NAME *name, UINT days, X_SERIAL *serial)
|
||||
X509_set_version(x509, 2L);
|
||||
|
||||
// Set the Expiration
|
||||
t1 = X509_get_notBefore(x509);
|
||||
t2 = X509_get_notAfter(x509);
|
||||
t1 = X509_get0_notBefore(x509);
|
||||
t2 = X509_get0_notAfter(x509);
|
||||
if (!UINT64ToAsn1Time(t1, notBefore))
|
||||
{
|
||||
FreeX509(x509);
|
||||
@ -1742,7 +1750,7 @@ X509 *NewRootX509(K *pub, K *priv, NAME *name, UINT days, X_SERIAL *serial)
|
||||
{
|
||||
X509 *x509;
|
||||
UINT64 notBefore, notAfter;
|
||||
ASN1_TIME *t1, *t2;
|
||||
const ASN1_TIME *t1, *t2;
|
||||
X509_NAME *subject_name, *issuer_name;
|
||||
X509_EXTENSION *ex = NULL;
|
||||
X509_EXTENSION *eku = NULL;
|
||||
@ -1780,8 +1788,8 @@ X509 *NewRootX509(K *pub, K *priv, NAME *name, UINT days, X_SERIAL *serial)
|
||||
X509_set_version(x509, 2L);
|
||||
|
||||
// Set the Expiration
|
||||
t1 = X509_get_notBefore(x509);
|
||||
t2 = X509_get_notAfter(x509);
|
||||
t1 = X509_get0_notBefore(x509);
|
||||
t2 = X509_get0_notAfter(x509);
|
||||
if (!UINT64ToAsn1Time(t1, notBefore))
|
||||
{
|
||||
FreeX509(x509);
|
||||
@ -3721,7 +3729,7 @@ void FreeCryptLibrary()
|
||||
openssl_lock = NULL;
|
||||
// RAND_Free_For_SoftEther();
|
||||
OpenSSL_FreeLock();
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
#ifdef OPENSSL_FIPS
|
||||
FIPS_mode_set(0);
|
||||
#endif
|
||||
@ -3738,6 +3746,7 @@ void FreeCryptLibrary()
|
||||
#ifndef OPENSSL_NO_COMP
|
||||
SSL_COMP_free_compression_methods();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
// Initialize the Crypt library
|
||||
@ -3745,6 +3754,7 @@ void InitCryptLibrary()
|
||||
{
|
||||
char tmp[16];
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
|
||||
// RAND_Init_For_SoftEther()
|
||||
openssl_lock = NewLock();
|
||||
SSL_library_init();
|
||||
@ -3753,6 +3763,7 @@ void InitCryptLibrary()
|
||||
OpenSSL_add_all_digests();
|
||||
ERR_load_crypto_strings();
|
||||
SSL_load_error_strings();
|
||||
#endif
|
||||
|
||||
ssl_clientcert_index = SSL_get_ex_new_index(0, "struct SslClientCertInfo *", NULL, NULL, NULL);
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <openssl/rc4.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/sha.h>
|
||||
#include <openssl/rsa.h>
|
||||
#include <Mayaqua/Mayaqua.h>
|
||||
#include <Mayaqua/cryptoki.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user