JDK7 SSL对接问题忽略不支持的密码套件:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 [英] JDK7 SSL conenction Issue Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256

查看:1171
本文介绍了JDK7 SSL对接问题忽略不支持的密码套件:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立SSL连接(作为客户端),并且根据此Oracle文章如果您使用TLSv1.2并启用管辖权策略的增强版,则JDK7支持以下两种密码套件.

I am making a SSL connection (as client) and according to this Oracle article the following two cypher suits are supported in JDK7 if you use TLSv1.2 and enable the Strong version of the jurisdiction policy.

  • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
  • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256

但是,进行安全连接时,将忽略两种密码算法.

However the two cypher algorithms are ignored when making secure connection.

Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
Ignoring unsupported cipher suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
**Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384**
Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA256
**Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256**
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
Ignoring unsupported cipher suite: TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
Ignoring unsupported cipher suite: TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
Ignoring unsupported cipher suite: TLS_RSA_WITH_AES_128_CBC_SHA256
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
%% No cached client session
*** ClientHello, TLSv1.2
RandomCookie:  GMT: 1496192143 bytes = { 166, 200, 78, 178, 69, 10, 17, 174, 212, 142, 188, 108, 136, 152, 242, 222, 94, 231, 4, 86, 2, 99, 202, 4, 204, 130, 236, 120 }
Session ID:  {}
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA, SSL_RSA_WITH_RC4_128_MD5, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Compression Methods:  { 0 }
Extension elliptic_curves, curve names: {secp256r1, sect163k1, sect163r2, secp192r1, secp224r1, sect233k1, sect233r1, sect283k1, sect283r1, secp384r1, sect409k1, sect409r1, secp521r1, sect571k1, sect571r1, secp160k1, secp160r1, secp160r2, sect163r1, secp192k1, sect193r1, sect193r2, secp224k1, sect239k1, secp256k1}
Extension ec_point_formats, formats: [uncompressed]
Extension signature_algorithms, signature_algorithms: SHA512withECDSA, SHA512withRSA, SHA384withECDSA, SHA384withRSA, SHA256withECDSA, SHA256withRSA, SHA224withECDSA, SHA224withRSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA, MD5withRSA
Extension server_name, server_name: [host_name: api.sms.optus.com.au]
***
main, WRITE: **TLSv1.2** Handshake, length = 222
main, READ: TLSv1.2 Alert, length = 2
main, RECV TLSv1 ALERT:  fatal, handshake_failure
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
ERROR [main] (TestRest.java:42) - Error : 

我已经设置了TLSv1.2

I have set the TLSv1.2

  • -Dhttps.protocols = TLSv1.2

我已经安装了" JCE无限强度管辖权策略文件",并且可以通过运行以下代码来确认其已成功安装

I have installed the "JCE Unlimited Strength Jurisdiction Policy Files" and I can confirm its successfully installed by running the following code

try {
    int maxAllowedKeyLength = Cipher.getMaxAllowedKeyLength("AES");
    System.out.println("AES: " + maxAllowedKeyLength);
    return maxAllowedKeyLength >= 256;
} catch (NoSuchAlgorithmException e) {
    return false;
}

我认为JDK7不支持这两种密码算法,但在Oracle文章中误提了这两种密码算法?

I think the two cypher algorithms are not supported in JDK7 but mistakenly mentioned in the Oracle article?

注意:

  • 如果我在JDK8中运行c0ode,没有问题.
  • 我落后于firewal,必须设置代理.但是我不认为它与之相关,因为我可以毫无问题地连接JDK8.

推荐答案

在进行任何调整之前,已在SSLContextImpl.init中计算了已启用"密码列表的初始设置,而在Java7客户端中,初始协议列表仅是SSLv3和TLSv1(在最新版本中,由于POODLE,java.security将jdk.tls.disabledAlgorithms配置为删除SSLv3),因此这将禁用所有仅TLSv1.2的密码,这是该服务器唯一同意的密码.这是实际握手开始之前跟踪中的Ignoring unsupported消息的来源.

The initial setting of the 'enabled' ciphers list is computed in SSLContextImpl.init before any tailoring is done, and in Java7 client the initial protocol list is only SSLv3 and TLSv1 (and in recent versions java.security configures jdk.tls.disabledAlgorithms to remove SSLv3 because of POODLE) so this disables all TLSv1.2-only ciphers, which are the only ones this server will agree to. This is the source of the Ignoring unsupported messages in your trace before the actual handshake starts.

如果使用HttpsURLConnection,则需要同时设置 https.protocolshttps.cipherSuites(注意大写字母S)sysprops.如果直接使用SSLSocket,则需要同时调用.setEnabledProtocols包括(至少)TLSv1.2.setEnabledCipherSuites包括(至少)在Q中突出显示的密码套件之一,或替换/包装工厂来执行等效.

If using HttpsURLConnection you need to set both https.protocols and https.cipherSuites (note capital S) sysprops. If directly using SSLSocket you need to call both .setEnabledProtocols including (at least) TLSv1.2 and .setEnabledCipherSuites including (at least) one of the ciphersuites you highlighted in your Q, or substitute/wrap the factory to do the equivalent.

Java8不会出现问题,因为它的客户端和服务器默认协议列表为SSLv3,TLSv1,TLSv1.1,TLSv1.2,并且再次由jdk.tls.disabledAlgorithms

Java8 does not have the problem because its default protocol list for both client and server is SSLv3,TLSv1,TLSv1.1,TLSv1.2, again with SSLv3 removed by jdk.tls.disabledAlgorithms

这篇关于JDK7 SSL对接问题忽略不支持的密码套件:TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆