@@ -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