Skip to content

Commit bcc232d

Browse files
committed
updated the test to apply -startdate -1M to all unspecified certificates
1 parent 065d82c commit bcc232d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ public class ConciseJarsigner {
4343
static OutputAnalyzer kt(String cmd) throws Exception {
4444
// Choose 2048-bit RSA to make sure it runs fine and fast. In
4545
// fact, every keyalg/keysize combination is OK for this test.
46-
return SecurityTools.keytool("-storepass changeit -keypass changeit "
47-
+ "-keystore ks -keyalg rsa -keysize 2048 " + cmd);
46+
// The start date is set to -1M to prevent the certificate not yet valid during fast enough execution.
47+
// If -startdate is specified in cmd, cmd version will be used.
48+
if (cmd.contains("-startdate")) {
49+
return SecurityTools.keytool("-storepass changeit -keypass changeit "
50+
+ "-keystore ks -keyalg rsa -keysize 2048 " + cmd);
51+
} else {
52+
return SecurityTools.keytool("-storepass changeit -keypass changeit "
53+
+ "-keystore ks -keyalg rsa -keysize 2048 -startdate -1M " + cmd);
54+
}
4855
}
4956

5057
static void gencert(String owner, String cmd) throws Exception {
@@ -256,9 +263,9 @@ public static void main(String[] args) throws Exception {
256263

257264
// This certchain contains a cross-signed weak catwo.cert
258265
Files.write(Path.of("ee2"), List.of(
259-
kt("-gencert -alias catwo -rfc -infile ee.req -startdate -1M").getOutput(),
266+
kt("-gencert -alias catwo -rfc -infile ee.req").getOutput(),
260267
kt("-gencert -alias caone -sigalg MD5withRSA -rfc "
261-
+ "-infile catwo.req -startdate -1M").getOutput()));
268+
+ "-infile catwo.req").getOutput()));
262269

263270
kt("-importcert -alias ee -file ee2");
264271

0 commit comments

Comments
 (0)