chiark / gitweb /
tests: support Java setups where MD5 is not disabled by default
authorHans-Christoph Steiner <hans@eds.org>
Tue, 19 Sep 2017 18:01:15 +0000 (20:01 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Tue, 19 Sep 2017 18:16:08 +0000 (20:16 +0200)
For platforms using Java < 1.8.0_133, MD5 is still enabled for JAR
signatures.  Its just too painful to manage all this, so support this
in the tests.

tests/IsMD5Disabled.java [new file with mode: 0644]
tests/run-tests

diff --git a/tests/IsMD5Disabled.java b/tests/IsMD5Disabled.java
new file mode 100644 (file)
index 0000000..4844619
--- /dev/null
@@ -0,0 +1,22 @@
+
+import java.security.Security;
+import java.util.Locale;
+
+public class IsMD5Disabled {
+    public static void main(String[] args) throws Exception {
+        String daString = Security.getProperty("jdk.jar.disabledAlgorithms");
+        String[] algorithms = daString.trim().split(",");
+        boolean isMD5Disabled = true;
+        for (String alg : algorithms) {
+            if (alg.trim().toLowerCase(Locale.US).startsWith("md5")) {
+                isMD5Disabled = false;
+            }
+        }
+        if (isMD5Disabled) {
+            System.out.println("MD5 in jdk.jar.disabledAlgorithms: " + daString);
+        } else {
+            System.out.println("MD5 allowed for JAR signatures: " + daString);
+            System.exit(1);
+        }
+    }
+}
index 346e8cdd5f9da99126d017d810240c3eda8f323f..27dc651e8812ff14d28494f4ddd50d13436b2894 100755 (executable)
@@ -46,6 +46,11 @@ have_git_2_3() {
     python3 -c "import sys; from distutils.version import LooseVersion as V; sys.exit(V(sys.argv[3]) < V('2.3'))" `git --version`
 }
 
+is_MD5_disabled() {
+    javac $WORKSPACE/tests/IsMD5Disabled.java && java -cp $WORKSPACE/tests IsMD5Disabled
+    return $?
+}
+
 #------------------------------------------------------------------------------#
 # "main"