@@ -62,6 +62,11 @@ static void CleanupOpenSSLThreadLocks(void);
62
62
63
63
static bool crypto_initialized = false; /* GLOBAL_X */
64
64
65
+ #if OPENSSL_VERSION_NUMBER > 0x30000000
66
+ static OSSL_PROVIDER * legacy_provider = NULL ;
67
+ static OSSL_PROVIDER * default_provider = NULL ;
68
+ #endif
69
+
65
70
const char * CryptoLastErrorString ()
66
71
{
67
72
const char * errmsg = ERR_reason_error_string (ERR_get_error ());
@@ -81,8 +86,8 @@ void CryptoInitialize()
81
86
/* We need Blowfish for legacy encrypted network stuff and in OpenSSL
82
87
* 3+, it's only available when the legacy provider is loaded. And we
83
88
* also need the default provider. */
84
- OSSL_PROVIDER_load (NULL , "legacy" );
85
- OSSL_PROVIDER_load (NULL , "default" );
89
+ legacy_provider = OSSL_PROVIDER_load (NULL , "legacy" );
90
+ default_provider = OSSL_PROVIDER_load (NULL , "default" );
86
91
#endif
87
92
RandomSeed ();
88
93
@@ -113,6 +118,20 @@ void CryptoDeInitialize()
113
118
EVP_cleanup ();
114
119
CleanupOpenSSLThreadLocks ();
115
120
ERR_free_strings ();
121
+
122
+ #if OPENSSL_VERSION_NUMBER > 0x30000000
123
+ if (legacy_provider != NULL )
124
+ {
125
+ OSSL_PROVIDER_unload (legacy_provider );
126
+ legacy_provider = NULL ;
127
+ }
128
+ if (default_provider != NULL )
129
+ {
130
+ OSSL_PROVIDER_unload (default_provider );
131
+ default_provider = NULL ;
132
+ }
133
+ #endif
134
+
116
135
crypto_initialized = false;
117
136
}
118
137
}
0 commit comments