We use Oracle jdk 1.7.0_71 and Tomcat 7.0.55. Unfortunately we started to get the following exception during SSL connection between servers:
javax.net.ssl.SS
Following code piece worked for us in an enterprise environment under the following conditions;
setting the "allowUnsafeServerCertChange" and "allowUnsafeRenegotiation" via System.setProperty() calls during the bootstrap of the application doesn't have effect.
if (e.getCause() instanceof SSLHandshakeException) {
logger.debug("server https certificate has been altered");
try {
Class> c = Class.forName("sun.security.ssl.ClientHandshaker");
Field allowUnsafeServerCertChangeField = c.getDeclaredField("allowUnsafeServerCertChange");
allowUnsafeServerCertChangeField.setAccessible(true);
Field modifiersField = Field.class.getDeclaredField("modifiers");
modifiersField.setAccessible(true);
modifiersField.setInt(allowUnsafeServerCertChangeField, allowUnsafeServerCertChangeField.getModifiers() & ~Modifier.FINAL);
allowUnsafeServerCertChangeField.set(null, true);
logger.debug("client has been updated in order to support SSL certificate change (re-negotiation) on runtime.");
}
catch (Exception ex) {
logger.debug("client cannot be updated to support SSL certificate change (re-negotiation) on runtime. Please restart the application.", ex);
}
}
Please note that this should be considered as a hack (introducing a vulnerability) and should be used in a trusted environment. One should try all the options in Yves' answer before going down this path.