From c0719605e79f7e91f528dd197dcb953f4ed99169 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Mon, 30 Nov 2020 13:31:47 +0000 Subject: [PATCH] 8257083: Security infra test failures caused by JDK-8202343 Reviewed-by: xuelei --- .../ssl/TLSCommon/interop/JdkProcClient.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java b/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java index ad6a067ed47..91d1a8d1ead 100644 --- a/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java +++ b/test/jdk/javax/net/ssl/TLSCommon/interop/JdkProcClient.java @@ -24,11 +24,12 @@ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; +import java.security.Security; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; -import jdk.test.lib.security.SecurityUtils; - /* * A JDK client process. */ @@ -161,7 +162,7 @@ public class JdkProcClient extends AbstractClient { String appProtocolsStr = System.getProperty(JdkProcUtils.PROP_APP_PROTOCOLS); // Re-enable TLSv1 and TLSv1.1 since client depends on them - SecurityUtils.removeFromDisabledTlsAlgs("TLSv1", "TLSv1.1"); + removeFromDisabledTlsAlgs("TLSv1", "TLSv1.1"); JdkClient.Builder builder = new JdkClient.Builder(); builder.setCertTuple(JdkProcUtils.createCertTuple( @@ -188,4 +189,22 @@ public class JdkProcClient extends AbstractClient { client.connect(host, port); } } + + /** + * Removes the specified protocols from the jdk.tls.disabledAlgorithms + * security property. + */ + private static void removeFromDisabledTlsAlgs(String... algs) { + List algList = Arrays.asList(algs); + String value = Security.getProperty("jdk.tls.disabledAlgorithms"); + StringBuilder newValue = new StringBuilder(); + for (String constraint : value.split(",")) { + String tmp = constraint.trim(); + if (!algList.contains(tmp)) { + newValue.append(tmp); + newValue.append(","); + } + } + Security.setProperty("jdk.tls.disabledAlgorithms", newValue.toString()); + } }