From f539d9886e3e0f3f1068e9e13af0988dae70377a Mon Sep 17 00:00:00 2001 From: exceptionfactory Date: Wed, 28 Jul 2021 17:57:22 -0500 Subject: [PATCH] NIFI-8956 Changed TestListenHTTP to expect IOException - Replaced expected SSLException with IOException in assertThrows - Removed conditional override of jdk.tls.disabledAlgorithms in test SslContextUtils Signed-off-by: Pierre Villard This closes #5260. --- .../processors/standard/TestListenHTTP.java | 5 ++--- .../nifi/web/util/ssl/SslContextUtils.java | 20 ------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenHTTP.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenHTTP.java index 1fa32add3c..48d911ec82 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenHTTP.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenHTTP.java @@ -31,7 +31,6 @@ import java.util.List; import java.util.Optional; import java.util.Random; import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLSession; import javax.net.ssl.SSLSocket; @@ -391,7 +390,7 @@ public class TestListenHTTP { public void testSecureServerTrustStoreConfiguredClientAuthenticationRequired() throws Exception { configureProcessorSslContextService(ListenHTTP.ClientAuthentication.REQUIRED, serverConfiguration); startSecureServer(); - assertThrows(SSLException.class, () -> postMessage(null, true, false)); + assertThrows(IOException.class, () -> postMessage(null, true, false)); } @Test @@ -493,7 +492,7 @@ public class TestListenHTTP { startWebServer(); } - private int postMessage(String message, boolean secure, boolean clientAuthRequired) throws Exception { + private int postMessage(String message, boolean secure, boolean clientAuthRequired) throws IOException { final OkHttpClient okHttpClient = getOkHttpClient(secure, clientAuthRequired); final Request.Builder requestBuilder = new Request.Builder(); final String url = buildUrl(secure); diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-web-test-utils/src/main/java/org/apache/nifi/web/util/ssl/SslContextUtils.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-web-test-utils/src/main/java/org/apache/nifi/web/util/ssl/SslContextUtils.java index b647b1a28a..0ca1fc442e 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-web-test-utils/src/main/java/org/apache/nifi/web/util/ssl/SslContextUtils.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-web-test-utils/src/main/java/org/apache/nifi/web/util/ssl/SslContextUtils.java @@ -22,31 +22,11 @@ import org.apache.nifi.security.util.SslContextFactory; import org.apache.nifi.security.util.StandardTlsConfiguration; import org.apache.nifi.security.util.TlsConfiguration; import org.apache.nifi.security.util.TlsException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.net.ssl.SSLContext; import java.io.File; -import java.security.Security; public class SslContextUtils { - private static final Logger LOGGER = LoggerFactory.getLogger(SslContextUtils.class); - - private static final String TLS_DISABLED_ALGORITHMS_PROPERTY = "jdk.tls.disabledAlgorithms"; - - private static final String DISABLED_ALGORITHMS = "SSLv3, RC4, DES, MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, include jdk.disabled.namedCurves"; - - static { - final String disabledAlgorithms = Security.getProperty(TLS_DISABLED_ALGORITHMS_PROPERTY); - if (DISABLED_ALGORITHMS.equals(disabledAlgorithms)) { - LOGGER.debug("Found Expected Default TLS Disabled Algorithms: {}", DISABLED_ALGORITHMS); - } else { - LOGGER.warn("Found System Default TLS Disabled Algorithms: {}", disabledAlgorithms); - LOGGER.warn("Setting TLS Disabled Algorithms: {}", DISABLED_ALGORITHMS); - Security.setProperty(TLS_DISABLED_ALGORITHMS_PROPERTY, DISABLED_ALGORITHMS); - } - } - private static final String KEYSTORE_PATH = "src/test/resources/keystore.jks"; private static final String KEYSTORE_AND_TRUSTSTORE_PASSWORD = "passwordpassword";