601982
From 42693cba452efa00a4848beb1514229149520cc1 Mon Sep 17 00:00:00 2001
601982
From: Alexander Scheel <ascheel@redhat.com>
601982
Date: Wed, 5 Aug 2020 11:39:45 -0400
601982
Subject: [PATCH] Ignore user-provided dhparams in FIPS mode (#3554)
601982
601982
OpenSSL in RHEL 8.3 introduces a breaking change in FIPS mode:
601982
user-provided dhparams will be ignored (and dhparam generation
601982
may fail as well), unless they are on the FIPS approved list of
601982
parameters. However, OpenSSL since v1.1.1 will automatically select
601982
an appropriate DH parameter set anyways, if the user did not provide
601982
any. These will be FIPS approved.
601982
601982
Signed-off-by: Alexander Scheel <ascheel@redhat.com>
601982
---
601982
 src/main/tls.c | 17 +++++++++++++++++
601982
 1 file changed, 17 insertions(+)
601982
601982
diff --git a/src/main/tls.c b/src/main/tls.c
601982
index 5809a1bd7d..5e6493333c 100644
601982
--- a/src/main/tls.c
601982
+++ b/src/main/tls.c
601982
@@ -1352,6 +1352,23 @@ static int load_dh_params(SSL_CTX *ctx, char *file)
601982
601982
 	if (!file) return 0;
601982
601982
+	/*
601982
+	 * Prior to trying to load the file, check what OpenSSL will do with it.
601982
+	 *
601982
+	 * Certain downstreams (such as RHEL) will ignore user-provided dhparams
601982
+	 * in FIPS mode, unless the specified parameters are FIPS-approved.
601982
+	 * However, since OpenSSL >= 1.1.1 will automatically select parameters
601982
+	 * anyways, there's no point in attempting to load them.
601982
+	 *
601982
+	 * Change suggested by @t8m
601982
+	 */
601982
+#if OPENSSL_VERSION_NUMBER >= 0x10101000L
601982
+	if (FIPS_mode() > 0) {
601982
+		WARN(LOG_PREFIX ": Ignoring user-selected DH parameters in FIPS mode. Using defaults.");
601982
+		return 0;
601982
+	}
601982
+#endif
601982
+
601982
 	if ((bio = BIO_new_file(file, "r")) == NULL) {
601982
 		ERROR(LOG_PREFIX ": Unable to open DH file - %s", file);
601982
 		return -1;