1 /* 2 * Copyright (c) 2012, 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 // SunJSSE does not support dynamic system properties, no way to re-use 26 // system properties in samevm/agentvm mode. 27 // 28 29 /* 30 * @test 31 * @bug 7068321 32 * @summary Support TLS Server Name Indication (SNI) Extension in JSSE Server 33 * @library ../SSLEngine ../templates 34 * @build SSLEngineService SSLCapabilities SSLExplorer 35 * @run main/othervm SSLEngineExplorer SSLv2Hello,SSLv3 36 * @run main/othervm SSLEngineExplorer SSLv3 37 * @run main/othervm SSLEngineExplorer TLSv1 38 * @run main/othervm SSLEngineExplorer TLSv1.1 39 * @run main/othervm SSLEngineExplorer TLSv1.2 40 */ 41 42 import javax.net.ssl.*; 43 import java.nio.*; 44 import java.net.*; 45 import java.util.*; 46 import java.nio.channels.*; 47 import java.security.Security; 48 49 public class SSLEngineExplorer extends SSLEngineService { 50 51 /* 63 64 // Is the server ready to serve? 65 volatile static boolean serverReady = false; 66 67 /* 68 * Turn on SSL debugging? 69 */ 70 static boolean debug = false; 71 72 /* 73 * Define the server side of the test. 74 * 75 * If the server prematurely exits, serverReady will be set to true 76 * to avoid infinite hangs. 77 */ 78 void doServerSide() throws Exception { 79 80 // create SSLEngine. 81 SSLEngine ssle = createSSLEngine(false); 82 83 // Create a server socket channel. 84 InetSocketAddress isa = 85 new InetSocketAddress(InetAddress.getLocalHost(), serverPort); 86 ServerSocketChannel ssc = ServerSocketChannel.open(); 87 ssc.socket().bind(isa); 88 serverPort = ssc.socket().getLocalPort(); 89 90 // Signal Client, we're ready for his connect. 91 serverReady = true; 92 93 // Accept a socket channel. 94 SocketChannel sc = ssc.accept(); 95 sc.configureBlocking(false); 96 97 // Complete connection. 98 while (!sc.finishConnect()) { 99 Thread.sleep(50); 100 // waiting for the connection completed. 101 } 102 | 1 /* 2 * Copyright (c) 2012, 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 // SunJSSE does not support dynamic system properties, no way to re-use 26 // system properties in samevm/agentvm mode. 27 // 28 29 /* 30 * @test 31 * @bug 7068321 8190492 32 * @summary Support TLS Server Name Indication (SNI) Extension in JSSE Server 33 * @library ../SSLEngine ../templates 34 * @build SSLEngineService SSLCapabilities SSLExplorer 35 * @run main/othervm SSLEngineExplorer SSLv2Hello,SSLv3 36 * @run main/othervm SSLEngineExplorer SSLv3 37 * @run main/othervm SSLEngineExplorer TLSv1 38 * @run main/othervm SSLEngineExplorer TLSv1.1 39 * @run main/othervm SSLEngineExplorer TLSv1.2 40 */ 41 42 import javax.net.ssl.*; 43 import java.nio.*; 44 import java.net.*; 45 import java.util.*; 46 import java.nio.channels.*; 47 import java.security.Security; 48 49 public class SSLEngineExplorer extends SSLEngineService { 50 51 /* 63 64 // Is the server ready to serve? 65 volatile static boolean serverReady = false; 66 67 /* 68 * Turn on SSL debugging? 69 */ 70 static boolean debug = false; 71 72 /* 73 * Define the server side of the test. 74 * 75 * If the server prematurely exits, serverReady will be set to true 76 * to avoid infinite hangs. 77 */ 78 void doServerSide() throws Exception { 79 80 // create SSLEngine. 81 SSLEngine ssle = createSSLEngine(false); 82 83 // Enable all supported protocols on server side to test SSLv3 84 ssle.setEnabledProtocols(ssle.getSupportedProtocols()); 85 86 // Create a server socket channel. 87 InetSocketAddress isa = 88 new InetSocketAddress(InetAddress.getLocalHost(), serverPort); 89 ServerSocketChannel ssc = ServerSocketChannel.open(); 90 ssc.socket().bind(isa); 91 serverPort = ssc.socket().getLocalPort(); 92 93 // Signal Client, we're ready for his connect. 94 serverReady = true; 95 96 // Accept a socket channel. 97 SocketChannel sc = ssc.accept(); 98 sc.configureBlocking(false); 99 100 // Complete connection. 101 while (!sc.finishConnect()) { 102 Thread.sleep(50); 103 // waiting for the connection completed. 104 } 105 |