Skip to content

Commit 9f0a043

Browse files
fguallinirhalade
authored andcommittedJan 26, 2021
8260286: Manual Test "ws/open/test/jdk/sun/security/tools/jarsigner/compatibility/Compatibility.java" fails
Reviewed-by: rhalade
1 parent fd00ed7 commit 9f0a043

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed
 

‎test/jdk/sun/security/tools/jarsigner/compatibility/Compatibility.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 8217375
26+
* @bug 8217375 8260286
2727
* @summary This test is used to verify the compatibility of jarsigner across
2828
* different JDK releases. It also can be used to check jar signing (w/
2929
* and w/o TSA) and to verify some specific signing and digest algorithms.
@@ -720,6 +720,7 @@ private static void verifying(SignItem signItem, VerifyItem verifyItem)
720720
expectedKeySize() + "-bit key"
721721
+ ")|("
722722
+ " Digest algorithm: " + signItem.expectedDigestAlg()
723+
+ (isWeakAlg(signItem.expectedDigestAlg()) ? " \\(weak\\)" : "")
723724
+ (signItem.tsaIndex < 0 ? "" :
724725
")|("
725726
+ "Timestamped by \".+\" on .*"
@@ -805,7 +806,12 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem
805806
boolean warning = false;
806807
for (String line : outputAnalyzer.getOutput().lines()
807808
.toArray(String[]::new)) {
808-
if (line.isBlank()) continue;
809+
if (line.isBlank()) {
810+
// If line is blank and warning flag is true, it is the end of warnings section
811+
// This is needed when some info is added after warnings, such as timestamp expiration date
812+
if (warning) warning = false;
813+
continue;
814+
}
809815
if (Test.JAR_VERIFIED.equals(line)) continue;
810816
if (line.matches(Test.ERROR + " ?") && expectedExitCode == 0) {
811817
System.out.println("verifyingStatus: error: line.matches(" + Test.ERROR + "\" ?\"): " + line);
@@ -835,6 +841,9 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem
835841
+ "not be able to validate this jar after the signer "
836842
+ "certificate's expiration date \\([^\\)]+\\) or after "
837843
+ "any future revocation date[.]") && !tsa) continue;
844+
845+
if (isWeakAlg(signItem.expectedDigestAlg())
846+
&& line.contains(Test.WEAK_ALGORITHM_WARNING)) continue;
838847
if (Test.CERTIFICATE_SELF_SIGNED.equals(line)) continue;
839848
if (Test.HAS_EXPIRED_CERT_VERIFYING_WARNING.equals(line)
840849
&& signItem.certInfo.expired) continue;
@@ -844,6 +853,10 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem
844853
return warning ? Status.WARNING : Status.NORMAL;
845854
}
846855

856+
private static boolean isWeakAlg(String alg) {
857+
return SHA1.equals(alg);
858+
}
859+
847860
// Using specified jarsigner to sign the pre-created jar with specified
848861
// algorithms.
849862
private static OutputAnalyzer signJar(String jarsignerPath, String sigalg,

‎test/jdk/sun/security/tools/jarsigner/warnings/Test.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -144,6 +144,10 @@ public abstract class Test {
144144
= "This jar contains entries "
145145
+ "whose signer certificate is not yet valid.";
146146

147+
static final String WEAK_ALGORITHM_WARNING
148+
= "algorithm is considered a security risk. "
149+
+ "This algorithm will be disabled in a future update.";
150+
147151
static final String JAR_SIGNED = "jar signed.";
148152

149153
static final String JAR_VERIFIED = "jar verified.";

0 commit comments

Comments
 (0)
Please sign in to comment.