Blob Blame History Raw
From bb1dd452d4b315f9dee533c9171974cab2565fbc Mon Sep 17 00:00:00 2001
From: David Sommerseth <davids@openvpn.net>
Date: Thu, 23 Mar 2017 01:34:06 +0100
Subject: [PATCH] workaround: Allow weaker RSA keys and MD algorithms in Fedora

This patch hard codes an alternative mbed TLS profile to allow
RSA keys >= 1024 bits as well as SHA1 and RIPEMD160 hashing.

v2 - Added MD5 support as well plus aligned PK alg and curve
     flags to what other implementations does.

Signed-off-by: David Sommerseth <davids@openvpn.net>
---
 src/openvpn/ssl_mbedtls.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/openvpn/ssl_mbedtls.c b/src/openvpn/ssl_mbedtls.c
index ba8dadf..37fa021 100644
--- a/src/openvpn/ssl_mbedtls.c
+++ b/src/openvpn/ssl_mbedtls.c
@@ -932,6 +932,33 @@ key_state_ssl_init(struct key_state_ssl *ks_ssl,
                                           MBEDTLS_SSL_CBC_RECORD_SPLITTING_DISABLED);
 #endif /* MBEDTLS_SSL_CBC_RECORD_SPLITTING */
 
+    /* Fedora adoption - allow legacy certificates
+     * Taken from the OpenVPN 3 Core code base with
+     * the addition of adding MD5 support as well.
+     */
+    const static mbedtls_x509_crt_profile crt_profile_legacy = {
+	MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_MD5 )  |
+	MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA1 ) |
+	MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_RIPEMD160 ) |
+	MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA224 ) |
+	MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA256 ) |
+	MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA384 ) |
+	MBEDTLS_X509_ID_FLAG( MBEDTLS_MD_SHA512 ),
+	0xFFFFFFF, /* Any PK alg    */
+	0xFFFFFFF, /* Any curve     */
+	1024,      /* Minimum size for RSA keys */
+    };
+    mbedtls_ssl_conf_cert_profile(&ks_ssl->ssl_config, &crt_profile_legacy);
+    static bool fedora_mod_info = false;
+    if (!fedora_mod_info) {
+	msg(M_INFO, "[Fedora modification] Switched mbed TLS certificate profile to legacy mode.");
+	msg(M_INFO, "[Fedora modification] Re-enabled MD5 certificate support. "
+		    "If you depend on MD5 certificates *UPDATE ASAP* They are *INSECURE*.");
+	fedora_mod_info = true;
+    }
+
+    /* End of Fedora adoption */
+
     /* Initialise authentication information */
     if (is_server)
     {
-- 
2.11.0