/* * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * Test that all ciphersuites work in all versions and all client * authentication types. The way this is setup the server is stateless and * all checking is done on the client side. * * The test is multithreaded to speed it up, especially on multiprocessor * machines. To simplify debugging, run with -DnumThreads=1. * * @author Andreas Sterbenz
*/ publicclass CipherTest {
// use any available port for the server socket staticvolatileint serverPort = 0;
if (!peerFactory.isSupported(cipherSuite, protocol)) { continue;
}
for (int k = 0; k < clientAuths.length; k++) {
String clientAuth = clientAuths[k]; // no client with anonymous cipher suites. // TLS_EMPTY_RENEGOTIATION_INFO_SCSV always be skipped. // TLS 1.3 is skipped due to the signature algorithm, // exactly MD5withRSA, in the certificates is not allowed. if ((clientAuth != null && cipherSuite.contains("DH_anon")
|| cipherSuite.equals(
CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV.name())
|| "TLSv1.3".equals(protocol))) { continue;
}
void sendRequest(InputStream in, OutputStream out) throws IOException {
out.write("GET / HTTP/1.0\r\n\r\n".getBytes());
out.flush();
StringBuilder sb = new StringBuilder(); while (true) { int ch = in.read(); if (ch < 0) { break;
}
sb.append((char)ch);
}
String response = sb.toString(); if (response.startsWith("HTTP/1.0 200 ") == false) { thrownew IOException("Invalid response: " + response);
}
}
}
// for some reason, ${test.src} has a different value when the // test is called from the script and when it is called directly... static String pathToStores = "."; static String pathToStoresSH = "."; static String keyStoreFile = "keystore"; static String trustStoreFile = "truststore"; staticchar[] passwd = "passphrase".toCharArray();
abstract Server newServer(CipherTest cipherTest) throws Exception;
boolean isSupported(String cipherSuite, String protocol) { // skip kerberos cipher suites if (cipherSuite.startsWith("TLS_KRB5")) {
System.out.println("Skipping unsupported test for " +
cipherSuite + " of " + protocol); returnfalse;
}
// skip SSLv2Hello protocol if (protocol.equals("SSLv2Hello")) {
System.out.println("Skipping unsupported test for " +
cipherSuite + " of " + protocol); returnfalse;
}
// ignore exportable cipher suite for TLSv1.1 if (protocol.equals("TLSv1.1")) { if (cipherSuite.indexOf("_EXPORT_WITH") != -1) {
System.out.println("Skipping obsoleted test for " +
cipherSuite + " of " + protocol); returnfalse;
}
}
returntrue;
}
}
}
// we currently don't do any chain verification. we assume that works ok // and we can speed up the test. we could also just add a plain certificate // chain comparision with our trusted certificates. class AlwaysTrustManager implements X509TrustManager {
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.