Path: blob/master/test/jdk/sun/security/ssl/ServerHandshaker/AnonCipherWithWantClientAuth.java
41152 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* @modules jdk.crypto.ec32* @library /javax/net/ssl/templates33* @summary Calling setWantClientAuth(true) disables anonymous suites34* @run main/othervm -Djavax.net.debug=all AnonCipherWithWantClientAuth35*/3637import java.io.InputStream;38import java.io.OutputStream;39import java.security.Security;40import javax.net.ssl.SSLSocket;4142public class AnonCipherWithWantClientAuth extends SSLSocketTemplate {43/*44* Run the test case.45*/46public static void main(String[] args) throws Exception {47// reset the security property to make sure that the algorithms48// and keys used in this test are not disabled.49Security.setProperty("jdk.tls.disabledAlgorithms", "");50Security.setProperty("jdk.certpath.disabledAlgorithms", "");5152(new AnonCipherWithWantClientAuth()).run();53}5455@Override56protected void runServerApplication(SSLSocket socket) throws Exception {57String ciphers[] = {58"SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",59"SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",60"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" };61socket.setEnabledCipherSuites(ciphers);62socket.setWantClientAuth(true);6364InputStream sslIS = socket.getInputStream();65OutputStream sslOS = socket.getOutputStream();6667sslIS.read();68sslOS.write(85);69sslOS.flush();70}7172@Override73protected void runClientApplication(SSLSocket socket) throws Exception {74String ciphers[] = {75"SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",76"SSL_DH_anon_EXPORT_WITH_RC4_40_MD5" };77socket.setEnabledCipherSuites(ciphers);78socket.setUseClientMode(true);7980InputStream sslIS = socket.getInputStream();81OutputStream sslOS = socket.getOutputStream();8283sslOS.write(280);84sslOS.flush();85sslIS.read();86}87}888990