1 /* 2 * Copyright (c) 2013, 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 // SunJSSE does not support dynamic system properties, no way to re-use 25 // system properties in samevm/agentvm mode. 26 27 /* 28 * @test 29 * @bug 7188658 30 * @summary Add possibility to disable client initiated renegotiation 31 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 32 * NoImpactServerRenego SSLv3 33 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 34 * NoImpactServerRenego TLSv1 35 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 36 * NoImpactServerRenego TLSv1.1 37 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 38 * NoImpactServerRenego TLSv1.2 39 */ 40 41 import java.io.*; 42 import java.net.*; 43 import java.security.Security; 44 import javax.net.ssl.*; 45 46 public class NoImpactServerRenego implements 47 HandshakeCompletedListener { 48 49 static byte handshakesCompleted = 0; 104 * Define the server side of the test. 105 * 106 * If the server prematurely exits, serverReady will be set to true 107 * to avoid infinite hangs. 108 */ 109 void doServerSide() throws Exception { 110 SSLServerSocketFactory sslssf = 111 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); 112 SSLServerSocket sslServerSocket = 113 (SSLServerSocket) sslssf.createServerSocket(serverPort); 114 115 serverPort = sslServerSocket.getLocalPort(); 116 117 /* 118 * Signal Client, we're ready for his connect. 119 */ 120 serverReady = true; 121 122 SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); 123 sslSocket.addHandshakeCompletedListener(this); 124 InputStream sslIS = sslSocket.getInputStream(); 125 OutputStream sslOS = sslSocket.getOutputStream(); 126 127 for (int i = 0; i < 10; i++) { 128 sslIS.read(); 129 sslOS.write(85); 130 sslOS.flush(); 131 } 132 133 System.out.println("invalidating"); 134 sslSocket.getSession().invalidate(); 135 System.out.println("starting new handshake"); 136 sslSocket.startHandshake(); 137 138 for (int i = 0; i < 10; i++) { 139 System.out.println("sending/receiving data, iteration: " + i); 140 sslIS.read(); 141 sslOS.write(85); 142 sslOS.flush(); 143 } | 1 /* 2 * Copyright (c) 2013, 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 // SunJSSE does not support dynamic system properties, no way to re-use 25 // system properties in samevm/agentvm mode. 26 27 /* 28 * @test 29 * @bug 7188658 8190492 30 * @summary Add possibility to disable client initiated renegotiation 31 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 32 * NoImpactServerRenego SSLv3 33 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 34 * NoImpactServerRenego TLSv1 35 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 36 * NoImpactServerRenego TLSv1.1 37 * @run main/othervm -Djdk.tls.rejectClientInitiatedRenegotiation=true 38 * NoImpactServerRenego TLSv1.2 39 */ 40 41 import java.io.*; 42 import java.net.*; 43 import java.security.Security; 44 import javax.net.ssl.*; 45 46 public class NoImpactServerRenego implements 47 HandshakeCompletedListener { 48 49 static byte handshakesCompleted = 0; 104 * Define the server side of the test. 105 * 106 * If the server prematurely exits, serverReady will be set to true 107 * to avoid infinite hangs. 108 */ 109 void doServerSide() throws Exception { 110 SSLServerSocketFactory sslssf = 111 (SSLServerSocketFactory) SSLServerSocketFactory.getDefault(); 112 SSLServerSocket sslServerSocket = 113 (SSLServerSocket) sslssf.createServerSocket(serverPort); 114 115 serverPort = sslServerSocket.getLocalPort(); 116 117 /* 118 * Signal Client, we're ready for his connect. 119 */ 120 serverReady = true; 121 122 SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept(); 123 sslSocket.addHandshakeCompletedListener(this); 124 125 // Enable all supported protocols on server side to test SSLv3 126 if ("SSLv3".equals(tlsProtocol)) { 127 sslSocket.setEnabledProtocols(sslSocket.getSupportedProtocols()); 128 } 129 130 InputStream sslIS = sslSocket.getInputStream(); 131 OutputStream sslOS = sslSocket.getOutputStream(); 132 133 for (int i = 0; i < 10; i++) { 134 sslIS.read(); 135 sslOS.write(85); 136 sslOS.flush(); 137 } 138 139 System.out.println("invalidating"); 140 sslSocket.getSession().invalidate(); 141 System.out.println("starting new handshake"); 142 sslSocket.startHandshake(); 143 144 for (int i = 0; i < 10; i++) { 145 System.out.println("sending/receiving data, iteration: " + i); 146 sslIS.read(); 147 sslOS.write(85); 148 sslOS.flush(); 149 } |