test/jdk/sun/net/www/protocol/https/HttpsURLConnection/DNSIdentities.java
changeset 58108 5302477c8285
parent 47216 71c04702a3d5
equal deleted inserted replaced
58106:79186d82463e 58108:5302477c8285
     1 /*
     1 /*
     2  * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   649     void doServerSide() throws Exception {
   649     void doServerSide() throws Exception {
   650         SSLContext context = getSSLContext(trusedCertStr, serverCertStr,
   650         SSLContext context = getSSLContext(trusedCertStr, serverCertStr,
   651             serverModulus, serverPrivateExponent, passphrase);
   651             serverModulus, serverPrivateExponent, passphrase);
   652         SSLServerSocketFactory sslssf = context.getServerSocketFactory();
   652         SSLServerSocketFactory sslssf = context.getServerSocketFactory();
   653 
   653 
       
   654         // doClientSide() connects to "localhost"
       
   655         InetAddress localHost = InetAddress.getByName("localhost");
       
   656         InetSocketAddress address = new InetSocketAddress(localHost, serverPort);
       
   657 
   654         sslServerSocket =
   658         sslServerSocket =
   655             (SSLServerSocket) sslssf.createServerSocket(serverPort);
   659             (SSLServerSocket) sslssf.createServerSocket();
       
   660         sslServerSocket.bind(address);
   656         serverPort = sslServerSocket.getLocalPort();
   661         serverPort = sslServerSocket.getLocalPort();
   657 
   662 
   658         /*
   663         /*
   659          * Signal Client, we're ready for his connect.
   664          * Signal Client, we're ready for his connect.
   660          */
   665          */
   715             /* establish http connection to server */
   720             /* establish http connection to server */
   716             URL url = new URL("https://localhost:" + serverPort+"/");
   721             URL url = new URL("https://localhost:" + serverPort+"/");
   717             System.out.println("url is "+url.toString());
   722             System.out.println("url is "+url.toString());
   718 
   723 
   719             try {
   724             try {
   720                 http = (HttpsURLConnection)url.openConnection();
   725                 http = (HttpsURLConnection)url.openConnection(Proxy.NO_PROXY);
   721 
   726 
   722                 int respCode = http.getResponseCode();
   727                 int respCode = http.getResponseCode();
   723                 System.out.println("respCode = "+respCode);
   728                 System.out.println("respCode = "+respCode);
   724             } finally {
   729             } finally {
   725                 if (http != null) {
   730                 if (http != null) {