在 jdk 1.7.0_79 中支持 TLSv1.1

Support for TLSv1.1 in jdk 1.7.0_79

我们已尝试使用以下代码来识别 java 1.7 版支持的协议。0_79

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);
}

上述程序的输出..

1.7.0_79 
Enabled protocols: 
TLSv1

为了支持 TLSv1.1,我们尝试了以下选项

in java.security 这也没有帮助。有人可以帮助确定要在 jdk 1.7.0_79 中完成的更改吗?

你快到了。你可以通过在 JDK 1.7.0_79 [=14= 的代码中添加以下条目来禁用 TLSv1.0 ]

sslSocket.setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});

更多解释请参考here

例子

SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslSocket = (SSLSocket) factory.createSocket();
sslSocket.setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
// Returns the names of the protocol versions which are
// currently enabled for use on this connection.
String[] protocols = sslSocket.getEnabledProtocols();

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

输出-

Enabled protocols:
TLSv1.1
TLSv1.2

其他方式

此外,如果您被允许迁移到 JDK1.8,那么默认情况下它会禁用 TLSv1.0 并支持 TLSv1.1,TLSv1 .2