test/jdk/java/net/httpclient/ssltest/CertificateTest.java
branchhttp-client-branch
changeset 56368 c10279a27b41
parent 56272 7394452786ba
child 56451 9585061fdb04
equal deleted inserted replaced
56367:875d85699981 56368:c10279a27b41
    46  *      -Djdk.internal.httpclient.disableHostnameVerification=false
    46  *      -Djdk.internal.httpclient.disableHostnameVerification=false
    47  *       CertificateTest bad.keystore expectFailure
    47  *       CertificateTest bad.keystore expectFailure
    48  * @run main/othervm
    48  * @run main/othervm
    49  *      -Djdk.internal.httpclient.disableHostnameVerification=xxyyzz
    49  *      -Djdk.internal.httpclient.disableHostnameVerification=xxyyzz
    50  *       CertificateTest bad.keystore expectFailure
    50  *       CertificateTest bad.keystore expectFailure
       
    51  * @run main/othervm CertificateTest loopback.keystore expectSuccess
    51  */
    52  */
    52 
    53 
    53 /**
    54 /**
    54  * The test runs a number of times. In all cases it uses a valid self-signed certificate
    55  * The test runs a number of times. In all cases it uses a valid self-signed certificate
    55  * that is installed in the trust store (so is trusted) and the same cert is supplied
    56  * that is installed in the trust store (so is trusted) and the same cert is supplied
   100         //params.setProtocols(new String[] { "TLSv1.2" });
   101         //params.setProtocols(new String[] { "TLSv1.2" });
   101     }
   102     }
   102 
   103 
   103     static void test(String[] args) throws Exception
   104     static void test(String[] args) throws Exception
   104     {
   105     {
   105         String uri_s = "https://localhost:" + Integer.toString(port) + "/foo";
   106         String uri_s;
       
   107         if (args[0].equals("loopback.keystore"))
       
   108             uri_s = "https://127.0.0.1:" + Integer.toString(port) + "/foo";
       
   109         else
       
   110             uri_s = "https://localhost:" + Integer.toString(port) + "/foo";
   106         String error = null;
   111         String error = null;
   107         Exception exception = null;
   112         Exception exception = null;
   108         System.out.println("Making request to " + uri_s);
   113         System.out.println("Making request to " + uri_s);
   109         HttpClient client = HttpClient.newBuilder()
   114         HttpClient client = HttpClient.newBuilder()
   110                 .sslContext(ctx)
   115                 .sslContext(ctx)