如何在 Java 中启用 SSL 3

How to enable SSL 3 in Java

自 Java 8 Update 31 起,SSL 3 协议由于 SSL 协议中的安全漏洞而默认禁用(参见 POODLE attack)。

即使不推荐,如何启用?

除非您别无选择,只能使用 SSL 3,下面的 link 解释了配置。

release notes for the update 31 提供了在 Java 中再次启用 SSL 3 的信息。

如前所述:

If SSLv3 is absolutely required, the protocol can be reactivated by removing "SSLv3" from the jdk.tls.disabledAlgorithms property in the java.security file or by dynamically setting this Security property to "true" before JSSE is initialized.

请记住,即使是 TLS 协议也可以被利用来允许使用 SSL 3 进行不安全的访问,这也是 POODLE 缺陷的一部分。为 Java 或任何其他技术启用此功能应该是出于关键原因的最后手段。

如果您必须在 8u31、7u75、6u91 上重新启用 SSLv3.0,您只需在 JRE_HOME/lib/security/java.security 中注释掉以下行:

 jdk.tls.disabledAlgorithms=SSLv3

代码:

import javax.net.ssl.*;

public class SocketProtocols {

  public static void main(String[] args) throws Exception {

    SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
    SSLSocket soc = (SSLSocket) factory.createSocket();

    // Returns the names of the protocol versions which are
    // currently enabled for use on this connection.
    String[] protocols = soc.getEnabledProtocols();

    System.out.println("Enabled protocols:");
    for (String s : protocols) {
      System.out.println(s);
    }

  }
} 

输出:

启用 SSL 3.0 之前

$ /jdk1.8.0_31/bin/java SocketProtocols
Enabled protocols:
TLSv1
TLSv1.1
TLSv1.2

启用 SSL 3.0 后

$ /jdk1.8.0_31/bin/java SocketProtocols
Enabled protocols:
SSLv3
TLSv1
TLSv1.1
TLSv1.2

credits/source: http://javablogx.blogspot.de/2015/02/enabling-ssl-v30-in-java-8.html

我发现需要进行这两项编辑才能连接到 DRAC 5 卡:

删除 MD5:

jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024

删除 SSLv3、RC4 和 MD5withRSA:

jdk.tls.disabledAlgorithms=DH keySize < 768

您可以像这样在运行时设置 jdk.tls.disabledAlgorithms 安全性 属性。

static {
    Security.setProperty("jdk.tls.disabledAlgorithms", "");
}