Blame SOURCES/winpr-ssl-Load-legacy-provider-when-initializing-Ope.patch

4cd190
From 2d0b58759ba823bbc372ac19fea5080f4261c26e Mon Sep 17 00:00:00 2001
4cd190
From: Ondrej Holy <oholy@redhat.com>
4cd190
Date: Tue, 16 Nov 2021 16:12:33 +0100
4cd190
Subject: [PATCH] winpr/ssl: Load legacy provider when initializing OpenSSL 3.0
4cd190
4cd190
With OpenSSL 3.O, FreeRDP log contains errors like:
4cd190
4cd190
```
4cd190
4036740A4C7F0000:error:0308010C:digital envelope routines:
4cd190
inner_evp_generic_fetch:unsupported:crypto/evp/evp_fetch.c:346:
4cd190
Global default library context, Algorithm (MD4 : 85), Properties ()
4cd190
```
4cd190
4cd190
This leads to connection failures in some cases. This is because algorithms
4cd190
like MD4 are now part of the legacy provider, which is not loaded by
4cd190
default. Let's explicitly load that provider. With this change, also the
4cd190
other provides has to be explicitely loaded.
4cd190
---
4cd190
 winpr/libwinpr/utils/ssl.c | 12 ++++++++++++
4cd190
 1 file changed, 12 insertions(+)
4cd190
4cd190
diff --git a/winpr/libwinpr/utils/ssl.c b/winpr/libwinpr/utils/ssl.c
4cd190
index 74ef156e7..392f8e227 100644
4cd190
--- a/winpr/libwinpr/utils/ssl.c
4cd190
+++ b/winpr/libwinpr/utils/ssl.c
4cd190
@@ -33,6 +33,10 @@
4cd190
 #include <openssl/ssl.h>
4cd190
 #include <openssl/err.h>
4cd190
 
4cd190
+#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
4cd190
+#include <openssl/provider.h>
4cd190
+#endif
4cd190
+
4cd190
 #include "../log.h"
4cd190
 #define TAG WINPR_TAG("utils.ssl")
4cd190
 
4cd190
@@ -245,6 +249,7 @@ static BOOL winpr_enable_fips(DWORD flags)
4cd190
 		WLog_DBG(TAG, "Ensuring openssl fips mode is ENabled");
4cd190
 
4cd190
 #if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
4cd190
+		OSSL_PROVIDER_load(NULL, "fips");
4cd190
 		if (!EVP_default_properties_is_fips_enabled(NULL))
4cd190
 #else
4cd190
 		if (FIPS_mode() != 1)
4cd190
@@ -305,6 +310,13 @@ static BOOL CALLBACK _winpr_openssl_initialize(PINIT_ONCE once, PVOID param, PVO
4cd190
 		return FALSE;
4cd190
 
4cd190
 #endif
4cd190
+
4cd190
+#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
4cd190
+	/* The legacy provider is needed for MD4. */
4cd190
+	OSSL_PROVIDER_load(NULL, "legacy");
4cd190
+	OSSL_PROVIDER_load(NULL, "default");
4cd190
+#endif
4cd190
+
4cd190
 	g_winpr_openssl_initialized_by_winpr = TRUE;
4cd190
 	return winpr_enable_fips(flags);
4cd190
 }
4cd190
-- 
4cd190
2.33.1
4cd190