11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 8157105 27 * @key intermittent 28 * @library /lib/testlibrary 29 * @build jdk.testlibrary.SimpleSSLContext 30 * @modules java.httpclient 31 * @compile/module=java.httpclient java/net/http/BodyOutputStream.java 32 * @compile/module=java.httpclient java/net/http/BodyInputStream.java 33 * @compile/module=java.httpclient java/net/http/EchoHandler.java 34 * @compile/module=java.httpclient java/net/http/Http2Handler.java 35 * @compile/module=java.httpclient java/net/http/Http2TestExchange.java 36 * @compile/module=java.httpclient java/net/http/Http2TestServerConnection.java 37 * @compile/module=java.httpclient java/net/http/Http2TestServer.java 38 * @compile/module=java.httpclient java/net/http/OutgoingPushPromise.java 39 * @compile/module=java.httpclient java/net/http/TestUtil.java 40 * @run testng/othervm -Djava.net.http.HttpClient.log=ssl,errors ErrorTest 41 * @summary check exception thrown when bad TLS parameters selected 42 */ 43 44 import java.io.*; 45 import java.net.*; 46 import java.net.http.*; 47 import static java.net.http.HttpClient.Version.HTTP_2; 48 import javax.net.ssl.*; 49 import java.nio.file.*; 50 import java.util.concurrent.*; 51 import jdk.testlibrary.SimpleSSLContext; 52 53 54 import org.testng.annotations.Test; 55 import org.testng.annotations.Parameters; 56 57 /** 58 * When selecting an unacceptable cipher suite the TLS handshake will fail. 59 * But, the exception that was thrown was not being returned up to application 60 * causing hang problems 61 */ 62 @Test 63 public class ErrorTest { 64 static int httpsPort; 65 static Http2TestServer httpsServer; 66 static HttpClient client = null; 67 static ExecutorService exec; 68 static SSLContext sslContext; 69 70 static String httpsURIString; 71 72 static HttpClient getClient() { 73 if (client == null) { 74 client = HttpClient.create() 75 .sslContext(sslContext) | 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 8157105 27 * @key intermittent 28 * @library /lib/testlibrary 29 * @build jdk.testlibrary.SimpleSSLContext 30 * @modules java.httpclient 31 * jdk.security.auth 32 * @compile/module=java.httpclient java/net/http/BodyOutputStream.java 33 * @compile/module=java.httpclient java/net/http/BodyInputStream.java 34 * @compile/module=java.httpclient java/net/http/EchoHandler.java 35 * @compile/module=java.httpclient java/net/http/Http2Handler.java 36 * @compile/module=java.httpclient java/net/http/Http2TestExchange.java 37 * @compile/module=java.httpclient java/net/http/Http2TestServerConnection.java 38 * @compile/module=java.httpclient java/net/http/Http2TestServer.java 39 * @compile/module=java.httpclient java/net/http/OutgoingPushPromise.java 40 * @compile/module=java.httpclient java/net/http/TestUtil.java 41 * @run testng/othervm -Djava.net.http.HttpClient.log=ssl,errors ErrorTest 42 * @summary check exception thrown when bad TLS parameters selected 43 */ 44 45 import java.io.IOException; 46 import java.net.URI; 47 import java.net.http.EchoHandler; 48 import java.net.http.HttpClient; 49 import java.net.http.Http2TestServer; 50 import java.net.http.HttpRequest; 51 import java.net.http.HttpResponse; 52 import java.util.concurrent.ExecutorService; 53 import javax.net.ssl.SSLContext; 54 import javax.net.ssl.SSLParameters; 55 import jdk.testlibrary.SimpleSSLContext; 56 57 import org.testng.annotations.Test; 58 59 import static java.net.http.HttpClient.Version.HTTP_2; 60 61 /** 62 * When selecting an unacceptable cipher suite the TLS handshake will fail. 63 * But, the exception that was thrown was not being returned up to application 64 * causing hang problems 65 */ 66 @Test 67 public class ErrorTest { 68 static int httpsPort; 69 static Http2TestServer httpsServer; 70 static HttpClient client = null; 71 static ExecutorService exec; 72 static SSLContext sslContext; 73 74 static String httpsURIString; 75 76 static HttpClient getClient() { 77 if (client == null) { 78 client = HttpClient.create() 79 .sslContext(sslContext) |