1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-11-26 11:29:53 +03:00

Merge pull request #1581 from domosekai/pkcs12

Fix PKCS12 import under OpenSSL 3.0
This commit is contained in:
Yihong Wu 2022-04-27 09:59:10 +08:00 committed by GitHub
commit 4c2e0867e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,9 @@
#include <openssl/pem.h> #include <openssl/pem.h>
#include <openssl/conf.h> #include <openssl/conf.h>
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
#include <openssl/provider.h>
#endif
#ifdef _MSC_VER #ifdef _MSC_VER
#include <intrin.h> // For __cpuid() #include <intrin.h> // For __cpuid()
@ -82,6 +85,11 @@ LOCK *openssl_lock = NULL;
int ssl_clientcert_index = 0; int ssl_clientcert_index = 0;
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
static OSSL_PROVIDER *ossl_provider_legacy = NULL;
static OSSL_PROVIDER *ossl_provider_default = NULL;
#endif
LOCK **ssl_lock_obj = NULL; LOCK **ssl_lock_obj = NULL;
UINT ssl_lock_num; UINT ssl_lock_num;
static bool openssl_inited = false; static bool openssl_inited = false;
@ -3948,6 +3956,20 @@ void FreeCryptLibrary()
SSL_COMP_free_compression_methods(); SSL_COMP_free_compression_methods();
#endif #endif
#endif #endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
if (ossl_provider_default != NULL)
{
OSSL_PROVIDER_unload(ossl_provider_default);
ossl_provider_default = NULL;
}
if (ossl_provider_legacy != NULL)
{
OSSL_PROVIDER_unload(ossl_provider_legacy);
ossl_provider_legacy = NULL;
}
#endif
} }
// Initialize the Crypt library // Initialize the Crypt library
@ -3966,6 +3988,11 @@ void InitCryptLibrary()
SSL_load_error_strings(); SSL_load_error_strings();
#endif #endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
ossl_provider_default = OSSL_PROVIDER_load(NULL, "legacy");
ossl_provider_legacy = OSSL_PROVIDER_load(NULL, "default");
#endif
ssl_clientcert_index = SSL_get_ex_new_index(0, "struct SslClientCertInfo *", NULL, NULL, NULL); ssl_clientcert_index = SSL_get_ex_new_index(0, "struct SslClientCertInfo *", NULL, NULL, NULL);
#ifdef OS_UNIX #ifdef OS_UNIX