Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java
38853 views
/*1* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223//24// SunJSSE does not support dynamic system properties, no way to re-use25// system properties in samevm/agentvm mode.26//2728/*29* @test30* @bug 439247531* @library /javax/net/ssl/templates32* @summary Calling setWantClientAuth(true) disables anonymous suites33* @run main/othervm -Djavax.net.debug=all AnonCipherWithWantClientAuth34*/3536import java.io.InputStream;37import java.io.OutputStream;38import java.security.Security;39import javax.net.ssl.SSLSocket;4041public class AnonCipherWithWantClientAuth extends SSLSocketTemplate {42/*43* Run the test case.44*/45public static void main(String[] args) throws Exception {46// reset the security property to make sure that the algorithms47// and keys used in this test are not disabled.48Security.setProperty("jdk.tls.disabledAlgorithms", "");49Security.setProperty("jdk.certpath.disabledAlgorithms", "");5051(new AnonCipherWithWantClientAuth()).run();52}5354@Override55protected void runServerApplication(SSLSocket socket) throws Exception {56String ciphers[] = {57"SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",58"SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",59"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" };60socket.setEnabledCipherSuites(ciphers);61socket.setWantClientAuth(true);6263InputStream sslIS = socket.getInputStream();64OutputStream sslOS = socket.getOutputStream();6566sslIS.read();67sslOS.write(85);68sslOS.flush();69}7071@Override72protected void runClientApplication(SSLSocket socket) throws Exception {73String ciphers[] = {74"SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",75"SSL_DH_anon_EXPORT_WITH_RC4_40_MD5" };76socket.setEnabledCipherSuites(ciphers);77socket.setUseClientMode(true);7879InputStream sslIS = socket.getInputStream();80OutputStream sslOS = socket.getOutputStream();8182sslOS.write(280);83sslOS.flush();84sslIS.read();85}86}878889