RFR 8190674: sun/security/tools/jarsigner/TimestampCheck.java failed with java.nio.file.NoSuchFileException: ts2.cert

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR 8190674: sun/security/tools/jarsigner/TimestampCheck.java failed with java.nio.file.NoSuchFileException: ts2.cert

Weijun Wang
Please review the fix. The comment said the test will try several times but when ts2.cert does not have the same size it is not regenerated at all, and a 2nd delete fails.

diff --git a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
--- a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
+++ b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
@@ -694,11 +694,12 @@
         gencert("ts", "-ext eku:critical=ts");
 
 
-        // Issue another cert for "ts" with a different EKU.
-        // Length should be the same. Try several times.
-        keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " +
-                "-ext eku:critical=1.3.6.1.5.5.7.3.9");
         for (int i = 0; i < 5; i++) {
+            // Issue another cert for "ts" with a different EKU.
+            // Length should be the same. Try several times.
+            // If cannot create one, related test will be ignored.
+            keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " +
+                    "-ext eku:critical=1.3.6.1.5.5.7.3.9");
             if (Files.size(Paths.get("ts.cert")) != Files.size(Paths.get("ts2.cert"))) {
                 Files.delete(Paths.get("ts2.cert"));
                 System.out.println("Warning: cannot create same length");
             } else {
                 break;
             }
         }

Thanks
Max

Reply | Threaded
Open this post in threaded view
|

Re: RFR 8190674: sun/security/tools/jarsigner/TimestampCheck.java failed with java.nio.file.NoSuchFileException: ts2.cert

Sean Mullan
Looks good, but can you add some additional comments explaining why the
sizes need to be identical and why sometimes they can be different?

--Sean

On 11/30/17 10:26 PM, Weijun Wang wrote:

> Please review the fix. The comment said the test will try several times but when ts2.cert does not have the same size it is not regenerated at all, and a 2nd delete fails.
>
> diff --git a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
> --- a/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
> +++ b/test/jdk/sun/security/tools/jarsigner/TimestampCheck.java
> @@ -694,11 +694,12 @@
>           gencert("ts", "-ext eku:critical=ts");
>  
>  
> -        // Issue another cert for "ts" with a different EKU.
> -        // Length should be the same. Try several times.
> -        keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " +
> -                "-ext eku:critical=1.3.6.1.5.5.7.3.9");
>           for (int i = 0; i < 5; i++) {
> +            // Issue another cert for "ts" with a different EKU.
> +            // Length should be the same. Try several times.
> +            // If cannot create one, related test will be ignored.
> +            keytool("-gencert -alias ca -infile ts.req -outfile ts2.cert " +
> +                    "-ext eku:critical=1.3.6.1.5.5.7.3.9");
>               if (Files.size(Paths.get("ts.cert")) != Files.size(Paths.get("ts2.cert"))) {
>                   Files.delete(Paths.get("ts2.cert"));
>                   System.out.println("Warning: cannot create same length");
>               } else {
>                   break;
>               }
>           }
>
> Thanks
> Max
>