|
|
176549 |
diff --git a/src/share/lib/security/java.security-linux b/src/share/lib/security/java.security-linux
|
|
|
176549 |
--- openjdk/jdk/src/share/lib/security/java.security-linux
|
|
|
176549 |
+++ openjdk/jdk/src/share/lib/security/java.security-linux
|
|
|
176549 |
@@ -501,7 +501,7 @@
|
|
|
e1fe81 |
#
|
|
|
e1fe81 |
# Example:
|
|
|
e1fe81 |
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
|
|
|
176549 |
-jdk.tls.disabledAlgorithms=SSLv3, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
+jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
EC keySize < 224
|
|
|
e1fe81 |
|
|
|
e1fe81 |
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
|
|
|
176549 |
diff --git a/src/share/lib/security/java.security-macosx b/src/share/lib/security/java.security-macosx
|
|
|
176549 |
--- openjdk/jdk/src/share/lib/security/java.security-macosx
|
|
|
176549 |
+++ openjdk/jdk/src/share/lib/security/java.security-macosx
|
|
|
176549 |
@@ -506,7 +506,7 @@
|
|
|
e1fe81 |
#
|
|
|
e1fe81 |
# Example:
|
|
|
e1fe81 |
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
|
|
|
176549 |
-jdk.tls.disabledAlgorithms=SSLv3, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
+jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
EC keySize < 224
|
|
|
e1fe81 |
|
|
|
e1fe81 |
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
|
|
|
176549 |
diff --git a/src/share/lib/security/java.security-solaris b/src/share/lib/security/java.security-solaris
|
|
|
176549 |
--- openjdk/jdk/src/share/lib/security/java.security-solaris
|
|
|
176549 |
+++ openjdk/jdk/src/share/lib/security/java.security-solaris
|
|
|
176549 |
@@ -505,7 +505,7 @@
|
|
|
e1fe81 |
#
|
|
|
e1fe81 |
# Example:
|
|
|
e1fe81 |
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
|
|
|
176549 |
-jdk.tls.disabledAlgorithms=SSLv3, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
+jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
EC keySize < 224
|
|
|
e1fe81 |
|
|
|
e1fe81 |
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
|
|
|
176549 |
diff --git a/src/share/lib/security/java.security-windows b/src/share/lib/security/java.security-windows
|
|
|
176549 |
--- openjdk/jdk/src/share/lib/security/java.security-windows
|
|
|
176549 |
+++ openjdk/jdk/src/share/lib/security/java.security-windows
|
|
|
176549 |
@@ -506,7 +506,7 @@
|
|
|
e1fe81 |
#
|
|
|
e1fe81 |
# Example:
|
|
|
e1fe81 |
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
|
|
|
176549 |
-jdk.tls.disabledAlgorithms=SSLv3, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
+jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 768, \
|
|
|
176549 |
EC keySize < 224
|
|
|
e1fe81 |
|
|
|
e1fe81 |
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
|
|
|
176549 |
diff --git a/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java b/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java
|
|
|
176549 |
new file mode 100644
|
|
|
176549 |
--- /dev/null
|
|
|
176549 |
+++ openjdk/jdk/test/javax/net/ssl/ciphersuites/DisabledAlgorithms.java
|
|
|
e1fe81 |
@@ -0,0 +1,362 @@
|
|
|
e1fe81 |
+/*
|
|
|
e1fe81 |
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
|
|
e1fe81 |
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
e1fe81 |
+ *
|
|
|
e1fe81 |
+ * This code is free software; you can redistribute it and/or modify it
|
|
|
e1fe81 |
+ * under the terms of the GNU General Public License version 2 only, as
|
|
|
e1fe81 |
+ * published by the Free Software Foundation.
|
|
|
e1fe81 |
+ *
|
|
|
e1fe81 |
+ * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
e1fe81 |
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
e1fe81 |
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
e1fe81 |
+ * version 2 for more details (a copy is included in the LICENSE file that
|
|
|
e1fe81 |
+ * accompanied this code).
|
|
|
e1fe81 |
+ *
|
|
|
e1fe81 |
+ * You should have received a copy of the GNU General Public License version
|
|
|
e1fe81 |
+ * 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
e1fe81 |
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
e1fe81 |
+ *
|
|
|
e1fe81 |
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
e1fe81 |
+ * or visit www.oracle.com if you need additional information or have any
|
|
|
e1fe81 |
+ * questions.
|
|
|
e1fe81 |
+ */
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+import java.io.BufferedInputStream;
|
|
|
e1fe81 |
+import java.io.BufferedOutputStream;
|
|
|
e1fe81 |
+import java.io.IOException;
|
|
|
e1fe81 |
+import java.io.InputStream;
|
|
|
e1fe81 |
+import java.io.OutputStream;
|
|
|
e1fe81 |
+import java.security.NoSuchAlgorithmException;
|
|
|
e1fe81 |
+import java.security.Security;
|
|
|
e1fe81 |
+import java.util.concurrent.TimeUnit;
|
|
|
e1fe81 |
+import javax.net.ssl.SSLContext;
|
|
|
e1fe81 |
+import javax.net.ssl.SSLHandshakeException;
|
|
|
e1fe81 |
+import javax.net.ssl.SSLServerSocket;
|
|
|
e1fe81 |
+import javax.net.ssl.SSLServerSocketFactory;
|
|
|
e1fe81 |
+import javax.net.ssl.SSLSocket;
|
|
|
e1fe81 |
+import javax.net.ssl.SSLSocketFactory;
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+/**
|
|
|
e1fe81 |
+ * @test
|
|
|
e1fe81 |
+ * @bug 8076221
|
|
|
e1fe81 |
+ * @summary Check if weak cipher suites are disabled
|
|
|
e1fe81 |
+ * @run main/othervm DisabledAlgorithms default
|
|
|
e1fe81 |
+ * @run main/othervm DisabledAlgorithms empty
|
|
|
e1fe81 |
+ */
|
|
|
e1fe81 |
+public class DisabledAlgorithms {
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private static final String pathToStores =
|
|
|
e1fe81 |
+ "../../../../sun/security/ssl/etc";
|
|
|
e1fe81 |
+ private static final String keyStoreFile = "keystore";
|
|
|
e1fe81 |
+ private static final String trustStoreFile = "truststore";
|
|
|
e1fe81 |
+ private static final String passwd = "passphrase";
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private static final String keyFilename =
|
|
|
e1fe81 |
+ System.getProperty("test.src", "./") + "/" + pathToStores +
|
|
|
e1fe81 |
+ "/" + keyStoreFile;
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private static final String trustFilename =
|
|
|
e1fe81 |
+ System.getProperty("test.src", "./") + "/" + pathToStores +
|
|
|
e1fe81 |
+ "/" + trustStoreFile;
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ // supported RC4 cipher suites
|
|
|
e1fe81 |
+ // it does not contain KRB5 cipher suites because they need a KDC
|
|
|
e1fe81 |
+ private static final String[] rc4_ciphersuites = new String[] {
|
|
|
e1fe81 |
+ "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
|
|
|
e1fe81 |
+ "TLS_ECDHE_RSA_WITH_RC4_128_SHA",
|
|
|
e1fe81 |
+ "SSL_RSA_WITH_RC4_128_SHA",
|
|
|
e1fe81 |
+ "TLS_ECDH_ECDSA_WITH_RC4_128_SHA",
|
|
|
e1fe81 |
+ "TLS_ECDH_RSA_WITH_RC4_128_SHA",
|
|
|
e1fe81 |
+ "SSL_RSA_WITH_RC4_128_MD5",
|
|
|
e1fe81 |
+ "TLS_ECDH_anon_WITH_RC4_128_SHA",
|
|
|
e1fe81 |
+ "SSL_DH_anon_WITH_RC4_128_MD5"
|
|
|
e1fe81 |
+ };
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ public static void main(String[] args) throws Exception {
|
|
|
e1fe81 |
+ if (args.length < 1) {
|
|
|
e1fe81 |
+ throw new RuntimeException("No parameters specified");
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ System.setProperty("javax.net.ssl.keyStore", keyFilename);
|
|
|
e1fe81 |
+ System.setProperty("javax.net.ssl.keyStorePassword", passwd);
|
|
|
e1fe81 |
+ System.setProperty("javax.net.ssl.trustStore", trustFilename);
|
|
|
e1fe81 |
+ System.setProperty("javax.net.ssl.trustStorePassword", passwd);
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ switch (args[0]) {
|
|
|
e1fe81 |
+ case "default":
|
|
|
e1fe81 |
+ // use default jdk.tls.disabledAlgorithms
|
|
|
e1fe81 |
+ System.out.println("jdk.tls.disabledAlgorithms = "
|
|
|
e1fe81 |
+ + Security.getProperty("jdk.tls.disabledAlgorithms"));
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ // check if RC4 cipher suites can't be used by default
|
|
|
e1fe81 |
+ checkFailure(rc4_ciphersuites);
|
|
|
e1fe81 |
+ break;
|
|
|
e1fe81 |
+ case "empty":
|
|
|
e1fe81 |
+ // reset jdk.tls.disabledAlgorithms
|
|
|
e1fe81 |
+ Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
|
|
e1fe81 |
+ System.out.println("jdk.tls.disabledAlgorithms = "
|
|
|
e1fe81 |
+ + Security.getProperty("jdk.tls.disabledAlgorithms"));
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ // check if RC4 cipher suites can be used
|
|
|
e1fe81 |
+ // if jdk.tls.disabledAlgorithms is empty
|
|
|
e1fe81 |
+ checkSuccess(rc4_ciphersuites);
|
|
|
e1fe81 |
+ break;
|
|
|
e1fe81 |
+ default:
|
|
|
e1fe81 |
+ throw new RuntimeException("Wrong parameter: " + args[0]);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ /*
|
|
|
e1fe81 |
+ * Checks if that specified cipher suites cannot be used.
|
|
|
e1fe81 |
+ */
|
|
|
e1fe81 |
+ private static void checkFailure(String[] ciphersuites) throws Exception {
|
|
|
e1fe81 |
+ try (SSLServer server = SSLServer.init(ciphersuites)) {
|
|
|
e1fe81 |
+ startNewThread(server);
|
|
|
e1fe81 |
+ while (!server.isRunning()) {
|
|
|
e1fe81 |
+ sleep();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ int port = server.getPort();
|
|
|
e1fe81 |
+ for (String ciphersuite : ciphersuites) {
|
|
|
e1fe81 |
+ try (SSLClient client = SSLClient.init(port, ciphersuite)) {
|
|
|
e1fe81 |
+ client.connect();
|
|
|
e1fe81 |
+ throw new RuntimeException("Expected SSLHandshakeException "
|
|
|
e1fe81 |
+ + "not thrown");
|
|
|
e1fe81 |
+ } catch (SSLHandshakeException e) {
|
|
|
e1fe81 |
+ System.out.println("Expected exception on client side: "
|
|
|
e1fe81 |
+ + e);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ server.stop();
|
|
|
e1fe81 |
+ while (server.isRunning()) {
|
|
|
e1fe81 |
+ sleep();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ if (!server.sslError()) {
|
|
|
e1fe81 |
+ throw new RuntimeException("Expected SSL exception "
|
|
|
e1fe81 |
+ + "not thrown on server side");
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ /*
|
|
|
e1fe81 |
+ * Checks if specified cipher suites can be used.
|
|
|
e1fe81 |
+ */
|
|
|
e1fe81 |
+ private static void checkSuccess(String[] ciphersuites) throws Exception {
|
|
|
e1fe81 |
+ try (SSLServer server = SSLServer.init(ciphersuites)) {
|
|
|
e1fe81 |
+ startNewThread(server);
|
|
|
e1fe81 |
+ while (!server.isRunning()) {
|
|
|
e1fe81 |
+ sleep();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ int port = server.getPort();
|
|
|
e1fe81 |
+ for (String ciphersuite : ciphersuites) {
|
|
|
e1fe81 |
+ try (SSLClient client = SSLClient.init(port, ciphersuite)) {
|
|
|
e1fe81 |
+ client.connect();
|
|
|
e1fe81 |
+ String negotiated = client.getNegotiatedCipherSuite();
|
|
|
e1fe81 |
+ System.out.println("Negotiated cipher suite: "
|
|
|
e1fe81 |
+ + negotiated);
|
|
|
e1fe81 |
+ if (!negotiated.equals(ciphersuite)) {
|
|
|
e1fe81 |
+ throw new RuntimeException("Unexpected cipher suite: "
|
|
|
e1fe81 |
+ + negotiated);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ server.stop();
|
|
|
e1fe81 |
+ while (server.isRunning()) {
|
|
|
e1fe81 |
+ sleep();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ if (server.error()) {
|
|
|
e1fe81 |
+ throw new RuntimeException("Unexpected error on server side");
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private static Thread startNewThread(SSLServer server) {
|
|
|
e1fe81 |
+ Thread serverThread = new Thread(server, "SSL server thread");
|
|
|
e1fe81 |
+ serverThread.setDaemon(true);
|
|
|
e1fe81 |
+ serverThread.start();
|
|
|
e1fe81 |
+ return serverThread;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private static void sleep() {
|
|
|
e1fe81 |
+ try {
|
|
|
e1fe81 |
+ TimeUnit.MILLISECONDS.sleep(50);
|
|
|
e1fe81 |
+ } catch (InterruptedException e) {
|
|
|
e1fe81 |
+ // do nothing
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ static class SSLServer implements Runnable, AutoCloseable {
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private final SSLServerSocket ssocket;
|
|
|
e1fe81 |
+ private volatile boolean stopped = false;
|
|
|
e1fe81 |
+ private volatile boolean running = false;
|
|
|
e1fe81 |
+ private volatile boolean sslError = false;
|
|
|
e1fe81 |
+ private volatile boolean otherError = false;
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private SSLServer(SSLServerSocket ssocket) {
|
|
|
e1fe81 |
+ this.ssocket = ssocket;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ @Override
|
|
|
e1fe81 |
+ public void run() {
|
|
|
e1fe81 |
+ System.out.println("Server: started");
|
|
|
e1fe81 |
+ running = true;
|
|
|
e1fe81 |
+ while (!stopped) {
|
|
|
e1fe81 |
+ try (SSLSocket socket = (SSLSocket) ssocket.accept()) {
|
|
|
e1fe81 |
+ System.out.println("Server: accepted client connection");
|
|
|
e1fe81 |
+ InputStream in = socket.getInputStream();
|
|
|
e1fe81 |
+ OutputStream out = socket.getOutputStream();
|
|
|
e1fe81 |
+ int b = in.read();
|
|
|
e1fe81 |
+ if (b < 0) {
|
|
|
e1fe81 |
+ throw new IOException("Unexpected EOF");
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ System.out.println("Server: send data: " + b);
|
|
|
e1fe81 |
+ out.write(b);
|
|
|
e1fe81 |
+ out.flush();
|
|
|
e1fe81 |
+ socket.getSession().invalidate();
|
|
|
e1fe81 |
+ } catch (SSLHandshakeException e) {
|
|
|
e1fe81 |
+ System.out.println("Server: run: " + e);
|
|
|
e1fe81 |
+ sslError = true;
|
|
|
e1fe81 |
+ } catch (IOException e) {
|
|
|
e1fe81 |
+ if (!stopped) {
|
|
|
e1fe81 |
+ System.out.println("Server: run: " + e);
|
|
|
e1fe81 |
+ e.printStackTrace();
|
|
|
e1fe81 |
+ otherError = true;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ System.out.println("Server: finished");
|
|
|
e1fe81 |
+ running = false;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ int getPort() {
|
|
|
e1fe81 |
+ return ssocket.getLocalPort();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ String[] getEnabledCiperSuites() {
|
|
|
e1fe81 |
+ return ssocket.getEnabledCipherSuites();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ boolean isRunning() {
|
|
|
e1fe81 |
+ return running;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ boolean sslError() {
|
|
|
e1fe81 |
+ return sslError;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ boolean error() {
|
|
|
e1fe81 |
+ return sslError || otherError;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ void stop() {
|
|
|
e1fe81 |
+ stopped = true;
|
|
|
e1fe81 |
+ if (!ssocket.isClosed()) {
|
|
|
e1fe81 |
+ try {
|
|
|
e1fe81 |
+ ssocket.close();
|
|
|
e1fe81 |
+ } catch (IOException e) {
|
|
|
e1fe81 |
+ System.out.println("Server: close: " + e);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ @Override
|
|
|
e1fe81 |
+ public void close() {
|
|
|
e1fe81 |
+ stop();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ static SSLServer init(String[] ciphersuites)
|
|
|
e1fe81 |
+ throws IOException {
|
|
|
e1fe81 |
+ SSLServerSocketFactory ssf = (SSLServerSocketFactory)
|
|
|
e1fe81 |
+ SSLServerSocketFactory.getDefault();
|
|
|
e1fe81 |
+ SSLServerSocket ssocket = (SSLServerSocket)
|
|
|
e1fe81 |
+ ssf.createServerSocket(0);
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ if (ciphersuites != null) {
|
|
|
e1fe81 |
+ System.out.println("Server: enable cipher suites: "
|
|
|
e1fe81 |
+ + java.util.Arrays.toString(ciphersuites));
|
|
|
e1fe81 |
+ ssocket.setEnabledCipherSuites(ciphersuites);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ return new SSLServer(ssocket);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ static class SSLClient implements AutoCloseable {
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private final SSLSocket socket;
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ private SSLClient(SSLSocket socket) {
|
|
|
e1fe81 |
+ this.socket = socket;
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ void connect() throws IOException {
|
|
|
e1fe81 |
+ System.out.println("Client: connect to server");
|
|
|
e1fe81 |
+ try (
|
|
|
e1fe81 |
+ BufferedInputStream bis = new BufferedInputStream(
|
|
|
e1fe81 |
+ socket.getInputStream());
|
|
|
e1fe81 |
+ BufferedOutputStream bos = new BufferedOutputStream(
|
|
|
e1fe81 |
+ socket.getOutputStream())) {
|
|
|
e1fe81 |
+ bos.write('x');
|
|
|
e1fe81 |
+ bos.flush();
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ int read = bis.read();
|
|
|
e1fe81 |
+ if (read < 0) {
|
|
|
e1fe81 |
+ throw new IOException("Client: couldn't read a response");
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ socket.getSession().invalidate();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ String[] getEnabledCiperSuites() {
|
|
|
e1fe81 |
+ return socket.getEnabledCipherSuites();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ String getNegotiatedCipherSuite() {
|
|
|
e1fe81 |
+ return socket.getSession().getCipherSuite();
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ @Override
|
|
|
e1fe81 |
+ public void close() throws Exception {
|
|
|
e1fe81 |
+ if (!socket.isClosed()) {
|
|
|
e1fe81 |
+ try {
|
|
|
e1fe81 |
+ socket.close();
|
|
|
e1fe81 |
+ } catch (IOException e) {
|
|
|
e1fe81 |
+ System.out.println("Client: close: " + e);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ static SSLClient init(int port)
|
|
|
e1fe81 |
+ throws NoSuchAlgorithmException, IOException {
|
|
|
e1fe81 |
+ return init(port, null);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ static SSLClient init(int port, String ciphersuite)
|
|
|
e1fe81 |
+ throws NoSuchAlgorithmException, IOException {
|
|
|
e1fe81 |
+ SSLContext context = SSLContext.getDefault();
|
|
|
e1fe81 |
+ SSLSocketFactory ssf = (SSLSocketFactory)
|
|
|
e1fe81 |
+ context.getSocketFactory();
|
|
|
e1fe81 |
+ SSLSocket socket = (SSLSocket) ssf.createSocket("localhost", port);
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ if (ciphersuite != null) {
|
|
|
e1fe81 |
+ System.out.println("Client: enable cipher suite: "
|
|
|
e1fe81 |
+ + ciphersuite);
|
|
|
e1fe81 |
+ socket.setEnabledCipherSuites(new String[] { ciphersuite });
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ return new SSLClient(socket);
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+ }
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
+}
|
|
|
176549 |
diff --git a/test/sun/security/krb5/auto/SSL.java b/test/sun/security/krb5/auto/SSL.java
|
|
|
176549 |
--- openjdk/jdk/test/sun/security/krb5/auto/SSL.java
|
|
|
176549 |
+++ openjdk/jdk/test/sun/security/krb5/auto/SSL.java
|
|
|
e1fe81 |
@@ -1,5 +1,5 @@
|
|
|
e1fe81 |
/*
|
|
|
e1fe81 |
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
|
|
|
e1fe81 |
+ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
|
|
|
e1fe81 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
e1fe81 |
*
|
|
|
e1fe81 |
* This code is free software; you can redistribute it and/or modify it
|
|
|
e1fe81 |
@@ -40,6 +40,7 @@
|
|
|
e1fe81 |
import java.net.InetAddress;
|
|
|
e1fe81 |
import javax.net.ssl.*;
|
|
|
e1fe81 |
import java.security.Principal;
|
|
|
e1fe81 |
+import java.security.Security;
|
|
|
e1fe81 |
import java.util.Date;
|
|
|
e1fe81 |
import sun.security.jgss.GSSUtil;
|
|
|
e1fe81 |
import sun.security.krb5.PrincipalName;
|
|
|
e1fe81 |
@@ -54,6 +55,9 @@
|
|
|
e1fe81 |
private static volatile int port;
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public static void main(String[] args) throws Exception {
|
|
|
e1fe81 |
+ // reset the security property to make sure that the algorithms
|
|
|
e1fe81 |
+ // and keys used in this test are not disabled.
|
|
|
e1fe81 |
+ Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
|
|
e1fe81 |
|
|
|
e1fe81 |
krb5Cipher = args[0];
|
|
|
e1fe81 |
|
|
|
176549 |
diff --git a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/CipherSuiteOrder.java b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/CipherSuiteOrder.java
|
|
|
176549 |
--- openjdk/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/CipherSuiteOrder.java
|
|
|
176549 |
+++ openjdk/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/ClientHandshaker/CipherSuiteOrder.java
|
|
|
e1fe81 |
@@ -1,5 +1,5 @@
|
|
|
e1fe81 |
/*
|
|
|
e1fe81 |
- * Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
|
|
|
e1fe81 |
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
|
|
|
e1fe81 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
e1fe81 |
*
|
|
|
e1fe81 |
* This code is free software; you can redistribute it and/or modify it
|
|
|
e1fe81 |
@@ -36,7 +36,7 @@
|
|
|
e1fe81 |
*/
|
|
|
e1fe81 |
|
|
|
e1fe81 |
import java.io.*;
|
|
|
e1fe81 |
-import java.net.*;
|
|
|
e1fe81 |
+import java.security.Security;
|
|
|
e1fe81 |
import javax.net.ssl.*;
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public class CipherSuiteOrder {
|
|
|
e1fe81 |
@@ -198,6 +198,10 @@
|
|
|
e1fe81 |
volatile Exception clientException = null;
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public static void main(String[] args) throws Exception {
|
|
|
e1fe81 |
+ // reset the security property to make sure that the algorithms
|
|
|
e1fe81 |
+ // and keys used in this test are not disabled.
|
|
|
e1fe81 |
+ Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
String keyFilename =
|
|
|
e1fe81 |
System.getProperty("test.src", "./") + "/" + pathToStores +
|
|
|
e1fe81 |
"/" + keyStoreFile;
|
|
|
176549 |
diff --git a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java
|
|
|
176549 |
--- openjdk/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java
|
|
|
176549 |
+++ openjdk/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java
|
|
|
176549 |
@@ -103,10 +103,10 @@
|
|
|
176549 |
import java.security.Security;
|
|
|
e1fe81 |
import java.security.KeyStore;
|
|
|
e1fe81 |
import java.security.KeyFactory;
|
|
|
e1fe81 |
+import java.security.Security;
|
|
|
e1fe81 |
import java.security.cert.Certificate;
|
|
|
e1fe81 |
import java.security.cert.CertificateFactory;
|
|
|
e1fe81 |
import java.security.spec.PKCS8EncodedKeySpec;
|
|
|
e1fe81 |
-import java.security.spec.*;
|
|
|
e1fe81 |
import java.security.interfaces.*;
|
|
|
176549 |
import sun.misc.BASE64Decoder;
|
|
|
e1fe81 |
|
|
|
176549 |
diff --git a/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java b/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java
|
|
|
176549 |
--- openjdk/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java
|
|
|
176549 |
+++ openjdk/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java
|
|
|
e1fe81 |
@@ -1,5 +1,5 @@
|
|
|
e1fe81 |
/*
|
|
|
e1fe81 |
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
|
|
e1fe81 |
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
|
|
e1fe81 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
e1fe81 |
*
|
|
|
e1fe81 |
* This code is free software; you can redistribute it and/or modify it
|
|
|
e1fe81 |
@@ -622,6 +622,9 @@
|
|
|
e1fe81 |
}
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public static void main(String args[]) throws Exception {
|
|
|
e1fe81 |
+ // reset the security property to make sure that the algorithms
|
|
|
e1fe81 |
+ // and keys used in this test are not disabled.
|
|
|
e1fe81 |
+ Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
|
|
e1fe81 |
|
|
|
e1fe81 |
CheckStatus cs;
|
|
|
e1fe81 |
|
|
|
176549 |
diff --git a/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ConnectionTest.java b/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ConnectionTest.java
|
|
|
176549 |
--- openjdk/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ConnectionTest.java
|
|
|
176549 |
+++ openjdk/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/ConnectionTest.java
|
|
|
e1fe81 |
@@ -33,6 +33,8 @@
|
|
|
e1fe81 |
* The code could certainly be tightened up a lot.
|
|
|
e1fe81 |
*
|
|
|
e1fe81 |
* @author Brad Wetmore
|
|
|
e1fe81 |
+ *
|
|
|
e1fe81 |
+ * @run main/othervm ConnectionTest
|
|
|
e1fe81 |
*/
|
|
|
e1fe81 |
|
|
|
e1fe81 |
import javax.net.ssl.*;
|
|
|
e1fe81 |
@@ -672,6 +674,10 @@
|
|
|
e1fe81 |
}
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public static void main(String args[]) throws Exception {
|
|
|
e1fe81 |
+ // reset the security property to make sure that the algorithms
|
|
|
e1fe81 |
+ // and keys used in this test are not disabled.
|
|
|
e1fe81 |
+ Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
ConnectionTest ct = new ConnectionTest();
|
|
|
e1fe81 |
ct.test();
|
|
|
e1fe81 |
}
|
|
|
176549 |
diff --git a/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java b/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java
|
|
|
176549 |
--- openjdk/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java
|
|
|
176549 |
+++ openjdk/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java
|
|
|
e1fe81 |
@@ -180,6 +180,9 @@
|
|
|
e1fe81 |
}
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public static void main(String args[]) throws Exception {
|
|
|
e1fe81 |
+ // reset the security property to make sure that the algorithms
|
|
|
e1fe81 |
+ // and keys used in this test are not disabled.
|
|
|
e1fe81 |
+ Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
|
|
e1fe81 |
|
|
|
e1fe81 |
LargeBufs test;
|
|
|
e1fe81 |
|
|
|
176549 |
diff --git a/test/sun/security/ssl/javax/net/ssl/TLSv11/GenericStreamCipher.java b/test/sun/security/ssl/javax/net/ssl/TLSv11/GenericStreamCipher.java
|
|
|
176549 |
--- openjdk/jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/GenericStreamCipher.java
|
|
|
176549 |
+++ openjdk/jdk/test/sun/security/ssl/javax/net/ssl/TLSv11/GenericStreamCipher.java
|
|
|
e1fe81 |
@@ -37,7 +37,7 @@
|
|
|
e1fe81 |
*/
|
|
|
e1fe81 |
|
|
|
e1fe81 |
import java.io.*;
|
|
|
e1fe81 |
-import java.net.*;
|
|
|
e1fe81 |
+import java.security.Security;
|
|
|
e1fe81 |
import javax.net.ssl.*;
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public class GenericStreamCipher {
|
|
|
e1fe81 |
@@ -165,6 +165,10 @@
|
|
|
e1fe81 |
volatile Exception clientException = null;
|
|
|
e1fe81 |
|
|
|
e1fe81 |
public static void main(String[] args) throws Exception {
|
|
|
e1fe81 |
+ // reset the security property to make sure that the algorithms
|
|
|
e1fe81 |
+ // and keys used in this test are not disabled.
|
|
|
e1fe81 |
+ Security.setProperty("jdk.tls.disabledAlgorithms", "");
|
|
|
e1fe81 |
+
|
|
|
e1fe81 |
String keyFilename =
|
|
|
e1fe81 |
System.getProperty("test.src", ".") + "/" + pathToStores +
|
|
|
e1fe81 |
"/" + keyStoreFile;
|