boolean handshakeDone = false;
public void testRenegotiateFail() throws Exception {
+
+ // If RFC5746 is supported, renegotiation will always will (and will
+ // always be secure)
+ if (TesterSupport.RFC_5746_SUPPORTED) {
+ return;
+ }
+
Tomcat tomcat = getTomcatInstance();
File appDir = new File(getBuildDirectory(), "webapps/examples");
@Override
public void setUp() throws Exception {
- // Make sure SSL renegotiation is not disabled in the JVM
- System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
+ if (!TesterSupport.RFC_5746_SUPPORTED) {
+ // Make sure SSL renegotiation is not disabled in the JVM
+ System.setProperty("sun.security.ssl.allowUnsafeRenegotiation", "true");
+ }
super.setUp();
}
}
package org.apache.tomcat.util.net;
import java.io.File;
+import java.security.KeyManagementException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
import java.security.cert.X509Certificate;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLServerSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.catalina.startup.Tomcat;
public final class TesterSupport {
+
+ protected static final boolean RFC_5746_SUPPORTED;
+
+ static {
+ boolean result = false;
+ SSLContext context;
+ try {
+ context = SSLContext.getInstance("TLS");
+ context.init(null, null, new SecureRandom());
+ SSLServerSocketFactory ssf = context.getServerSocketFactory();
+ String ciphers[] = ssf.getSupportedCipherSuites();
+ for (String cipher : ciphers) {
+ if ("TLS_EMPTY_RENEGOTIATION_INFO_SCSV".equals(cipher)) {
+ result = true;
+ break;
+ }
+ }
+ } catch (NoSuchAlgorithmException e) {
+ // Assume no RFC 5746 support
+ } catch (KeyManagementException e) {
+ // Assume no RFC 5746 support
+ }
+ RFC_5746_SUPPORTED = result;
+ }
+
protected static final TrustManager[] TRUST_ALL_CERTS = new TrustManager[] {
new X509TrustManager() {
@Override
tomcat.getConnector().setSecure(true);
tomcat.getConnector().setProperty("SSLEnabled", "true");
}
+
}