1/* 2 * Copyright (c) 2001, 2017, 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 4392475 32 * @modules jdk.crypto.ec 33 * @library /javax/net/ssl/templates 34 * @summary Calling setWantClientAuth(true) disables anonymous suites 35 * @run main/othervm -Djavax.net.debug=all AnonCipherWithWantClientAuth 36 */ 37 38import java.io.InputStream; 39import java.io.OutputStream; 40import java.security.Security; 41import javax.net.ssl.SSLSocket; 42 43public class AnonCipherWithWantClientAuth extends SSLSocketTemplate { 44 /* 45 * Run the test case. 46 */ 47 public static void main(String[] args) throws Exception { 48 // reset the security property to make sure that the algorithms 49 // and keys used in this test are not disabled. 50 Security.setProperty("jdk.tls.disabledAlgorithms", ""); 51 Security.setProperty("jdk.certpath.disabledAlgorithms", ""); 52 53 (new AnonCipherWithWantClientAuth()).run(); 54 } 55 56 @Override 57 protected void runServerApplication(SSLSocket socket) throws Exception { 58 String ciphers[] = { 59 "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 60 "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5", 61 "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" }; 62 socket.setEnabledCipherSuites(ciphers); 63 socket.setWantClientAuth(true); 64 65 InputStream sslIS = socket.getInputStream(); 66 OutputStream sslOS = socket.getOutputStream(); 67 68 sslIS.read(); 69 sslOS.write(85); 70 sslOS.flush(); 71 } 72 73 @Override 74 protected void runClientApplication(SSLSocket socket) throws Exception { 75 String ciphers[] = { 76 "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA", 77 "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5" }; 78 socket.setEnabledCipherSuites(ciphers); 79 socket.setUseClientMode(true); 80 81 InputStream sslIS = socket.getInputStream(); 82 OutputStream sslOS = socket.getOutputStream(); 83 84 sslOS.write(280); 85 sslOS.flush(); 86 sslIS.read(); 87 } 88} 89