1
1
/*
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.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
23
23
24
24
/*
25
25
* @test
26
- * @bug 8217375
26
+ * @bug 8217375 8260286
27
27
* @summary This test is used to verify the compatibility of jarsigner across
28
28
* different JDK releases. It also can be used to check jar signing (w/
29
29
* 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)
720
720
expectedKeySize () + "-bit key"
721
721
+ ")|("
722
722
+ " Digest algorithm: " + signItem .expectedDigestAlg ()
723
+ + (isWeakAlg (signItem .expectedDigestAlg ()) ? " \\ (weak\\ )" : "" )
723
724
+ (signItem .tsaIndex < 0 ? "" :
724
725
")|("
725
726
+ "Timestamped by \" .+\" on .*"
@@ -805,7 +806,12 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem
805
806
boolean warning = false ;
806
807
for (String line : outputAnalyzer .getOutput ().lines ()
807
808
.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
+ }
809
815
if (Test .JAR_VERIFIED .equals (line )) continue ;
810
816
if (line .matches (Test .ERROR + " ?" ) && expectedExitCode == 0 ) {
811
817
System .out .println ("verifyingStatus: error: line.matches(" + Test .ERROR + "\" ?\" ): " + line );
@@ -835,6 +841,9 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem
835
841
+ "not be able to validate this jar after the signer "
836
842
+ "certificate's expiration date \\ ([^\\ )]+\\ ) or after "
837
843
+ "any future revocation date[.]" ) && !tsa ) continue ;
844
+
845
+ if (isWeakAlg (signItem .expectedDigestAlg ())
846
+ && line .contains (Test .WEAK_ALGORITHM_WARNING )) continue ;
838
847
if (Test .CERTIFICATE_SELF_SIGNED .equals (line )) continue ;
839
848
if (Test .HAS_EXPIRED_CERT_VERIFYING_WARNING .equals (line )
840
849
&& signItem .certInfo .expired ) continue ;
@@ -844,6 +853,10 @@ private static Status verifyingStatus(SignItem signItem, VerifyItem
844
853
return warning ? Status .WARNING : Status .NORMAL ;
845
854
}
846
855
856
+ private static boolean isWeakAlg (String alg ) {
857
+ return SHA1 .equals (alg );
858
+ }
859
+
847
860
// Using specified jarsigner to sign the pre-created jar with specified
848
861
// algorithms.
849
862
private static OutputAnalyzer signJar (String jarsignerPath , String sigalg ,
0 commit comments