1 /* 2 * Copyright (c) 2018, 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 package jdk.test.lib.security; 25 26 import java.io.*; 27 28 import javax.net.ssl.SSLSession; 29 import javax.net.ssl.SSLSocket; 30 31 32 public final class TestTLSHandshake extends SSLSocketTest { 33 34 public static final String CIPHER_SUITE = 35 "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"; 36 public static final int HASHCODE = -1057291798; 37 public static final int ANCHOR_HASHCODE = 1688661792; 38 public static final String CERT_SERIAL = "edbec8f705af2514"; 39 public static final String ANCHOR_CERT_SERIAL = "8e191778b2f331be"; 40 41 public String protocolVersion; 42 public String peerHost; 43 public int peerPort; 44 45 @Override 46 protected void runServerApplication(SSLSocket socket) throws Exception { 47 InputStream sslIS = socket.getInputStream(); 48 OutputStream sslOS = socket.getOutputStream(); 49 50 sslIS.read(); 51 sslOS.write(85); 52 sslOS.flush(); 53 } 54 55 @Override 56 protected void runClientApplication(SSLSocket socket) throws Exception { 57 socket.setEnabledCipherSuites(new String[] { CIPHER_SUITE }); 58 InputStream sslIS = socket.getInputStream(); 59 OutputStream sslOS = socket.getOutputStream(); 60 61 sslOS.write(280); 62 sslOS.flush(); 63 sslIS.read(); 64 65 SSLSession sslSession = socket.getSession(); 66 protocolVersion = sslSession.getProtocol(); 67 peerHost = sslSession.getPeerHost(); 68 peerPort = sslSession.getPeerPort(); 69 } 70 }