Fix OpenSSL initialization #299 (#300)

This commit is contained in:
Ján Osuský 2024-03-04 11:48:48 +01:00 committed by GitHub
parent 0ce327abee
commit d03ad5f0f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -115,10 +115,18 @@ void OpenSSLInitializer::initialize() {
OPENSSL_config(NULL);
#endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
static const bool isFIPSenabled = EVP_default_properties_is_fips_enabled(nullptr) == 1;
#else
static const bool isFIPSenabled = FIPS_mode() == 1;
#endif
#if OPENSSL_VERSION_NUMBER >=0x10100000L
OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS | OPENSSL_INIT_ADD_ALL_DIGESTS |
OPENSSL_INIT_LOAD_CONFIG | OPENSSL_INIT_ENGINE_OPENSSL | OPENSSL_INIT_ENGINE_ALL_BUILTIN , NULL);
OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS, NULL);
vmime_uint64 flags = OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CONFIG;
if (!isFIPSenabled) {
flags |= OPENSSL_INIT_ENGINE_OPENSSL | OPENSSL_INIT_ENGINE_ALL_BUILTIN;
}
OPENSSL_init_ssl(flags, NULL);
#endif
#if OPENSSL_VERSION_NUMBER < 0x10100000L