1 /*
2 * Copyright (c) 2008, 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 //
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 6728126
32 * @summary Parsing Extensions in Client Hello message is done in a wrong way
33 * @run main/othervm EmptyExtensionData
34 */
35
36 import javax.net.ssl.*;
37 import javax.net.ssl.SSLEngineResult.*;
38 import java.io.*;
39 import java.security.*;
40 import java.nio.*;
41
42 public class EmptyExtensionData {
43
44 private static boolean debug = false;
45
46 private static String pathToStores = "../../../../javax/net/ssl/etc";
47 private static String keyStoreFile = "keystore";
48 private static String trustStoreFile = "truststore";
49 private static String passwd = "passphrase";
50
51 private static String keyFilename =
52 System.getProperty("test.src", "./") + "/" + pathToStores +
137 */
138 private static void runDelegatedTasks(SSLEngineResult result,
139 SSLEngine engine) throws Exception {
140
141 if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
142 Runnable runnable;
143 while ((runnable = engine.getDelegatedTask()) != null) {
144 log("\trunning delegated task...");
145 runnable.run();
146 }
147 HandshakeStatus hsStatus = engine.getHandshakeStatus();
148 if (hsStatus == HandshakeStatus.NEED_TASK) {
149 throw new Exception(
150 "handshake shouldn't need additional tasks");
151 }
152 log("\tnew HandshakeStatus: " + hsStatus);
153 }
154 }
155
156 public static void main(String args[]) throws Exception {
157
158 SSLEngine ssle = createSSLEngine(keyFilename, trustFilename);
159 runTest(ssle);
160
161 System.out.println("Test Passed.");
162 }
163
164 /*
165 * Create an initialized SSLContext to use for this test.
166 */
167 static private SSLEngine createSSLEngine(String keyFile, String trustFile)
168 throws Exception {
169
170 SSLEngine ssle;
171
172 KeyStore ks = KeyStore.getInstance("JKS");
173 KeyStore ts = KeyStore.getInstance("JKS");
174
175 char[] passphrase = "passphrase".toCharArray();
176
|
1 /*
2 * Copyright (c) 2008, 2020, 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 6728126
32 * @summary Parsing Extensions in Client Hello message is done in a wrong way
33 * @library /lib/security
34 * @run main/othervm EmptyExtensionData
35 */
36
37 import javax.net.ssl.*;
38 import javax.net.ssl.SSLEngineResult.*;
39 import java.io.*;
40 import java.security.*;
41 import java.nio.*;
42
43 public class EmptyExtensionData {
44
45 private static boolean debug = false;
46
47 private static String pathToStores = "../../../../javax/net/ssl/etc";
48 private static String keyStoreFile = "keystore";
49 private static String trustStoreFile = "truststore";
50 private static String passwd = "passphrase";
51
52 private static String keyFilename =
53 System.getProperty("test.src", "./") + "/" + pathToStores +
138 */
139 private static void runDelegatedTasks(SSLEngineResult result,
140 SSLEngine engine) throws Exception {
141
142 if (result.getHandshakeStatus() == HandshakeStatus.NEED_TASK) {
143 Runnable runnable;
144 while ((runnable = engine.getDelegatedTask()) != null) {
145 log("\trunning delegated task...");
146 runnable.run();
147 }
148 HandshakeStatus hsStatus = engine.getHandshakeStatus();
149 if (hsStatus == HandshakeStatus.NEED_TASK) {
150 throw new Exception(
151 "handshake shouldn't need additional tasks");
152 }
153 log("\tnew HandshakeStatus: " + hsStatus);
154 }
155 }
156
157 public static void main(String args[]) throws Exception {
158 // Re-enable TLSv1 since test depends on it.
159 SecurityUtils.removeFromDisabledTlsAlgs("TLSv1");
160
161 SSLEngine ssle = createSSLEngine(keyFilename, trustFilename);
162 runTest(ssle);
163
164 System.out.println("Test Passed.");
165 }
166
167 /*
168 * Create an initialized SSLContext to use for this test.
169 */
170 static private SSLEngine createSSLEngine(String keyFile, String trustFile)
171 throws Exception {
172
173 SSLEngine ssle;
174
175 KeyStore ks = KeyStore.getInstance("JKS");
176 KeyStore ts = KeyStore.getInstance("JKS");
177
178 char[] passphrase = "passphrase".toCharArray();
179
|