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