1 /* 2 * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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 4671289 27 * @summary passing https.protocols from command line doesn't work. 28 * @run main/othervm -Dhttps.protocols=SSLv3 HttpsProtocols 29 * @author Brad Wetmore 30 */ 31 32 import java.io.*; 33 import java.net.*; 34 import javax.net.ssl.*; 35 import java.security.Security; 36 37 public class HttpsProtocols implements HostnameVerifier { 38 39 /* 40 * ============================================================= 41 * Set the various variables needed for the tests, then 42 * specify what tests to run on each side. 43 */ 44 45 /* 46 * Should we run the client or server in a separate thread? 71 * If the client or server is doing some kind of object creation 72 * that the other side depends on, and that thread prematurely 73 * exits, you may experience a hang. The test harness will 74 * terminate all hung threads after its timeout has expired, 75 * currently 3 minutes by default, but you might try to be 76 * smart about it.... 77 */ 78 79 /* 80 * Define the server side of the test. 81 * 82 * If the server prematurely exits, serverReady will be set to true 83 * to avoid infinite hangs. 84 */ 85 void doServerSide() throws Exception { 86 SSLServerSocketFactory sslssf = 87 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); 88 SSLServerSocket sslServerSocket = 89 (SSLServerSocket) sslssf.createServerSocket(serverPort); 90 91 serverPort = sslServerSocket.getLocalPort(); 92 93 /* 94 * Signal Client, we're ready for his connect. 95 */ 96 serverReady = true; 97 98 SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); 99 100 DataOutputStream out = 101 new DataOutputStream(sslSocket.getOutputStream()); 102 103 BufferedReader in = 104 new BufferedReader(new InputStreamReader( 105 sslSocket.getInputStream())); 106 107 // read the request 108 readRequest(in); 109 110 byte [] bytecodes = "Hello world".getBytes(); | 1 /* 2 * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 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 4671289 8190492 27 * @summary passing https.protocols from command line doesn't work. 28 * @run main/othervm -Dhttps.protocols=SSLv3 HttpsProtocols 29 * @author Brad Wetmore 30 */ 31 32 import java.io.*; 33 import java.net.*; 34 import javax.net.ssl.*; 35 import java.security.Security; 36 37 public class HttpsProtocols implements HostnameVerifier { 38 39 /* 40 * ============================================================= 41 * Set the various variables needed for the tests, then 42 * specify what tests to run on each side. 43 */ 44 45 /* 46 * Should we run the client or server in a separate thread? 71 * If the client or server is doing some kind of object creation 72 * that the other side depends on, and that thread prematurely 73 * exits, you may experience a hang. The test harness will 74 * terminate all hung threads after its timeout has expired, 75 * currently 3 minutes by default, but you might try to be 76 * smart about it.... 77 */ 78 79 /* 80 * Define the server side of the test. 81 * 82 * If the server prematurely exits, serverReady will be set to true 83 * to avoid infinite hangs. 84 */ 85 void doServerSide() throws Exception { 86 SSLServerSocketFactory sslssf = 87 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); 88 SSLServerSocket sslServerSocket = 89 (SSLServerSocket) sslssf.createServerSocket(serverPort); 90 91 // Enable all supported protocols on server side to test SSLv3 92 sslServerSocket.setEnabledProtocols(sslServerSocket.getSupportedProtocols()); 93 94 serverPort = sslServerSocket.getLocalPort(); 95 96 /* 97 * Signal Client, we're ready for his connect. 98 */ 99 serverReady = true; 100 101 SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); 102 103 DataOutputStream out = 104 new DataOutputStream(sslSocket.getOutputStream()); 105 106 BufferedReader in = 107 new BufferedReader(new InputStreamReader( 108 sslSocket.getInputStream())); 109 110 // read the request 111 readRequest(in); 112 113 byte [] bytecodes = "Hello world".getBytes(); |