ECDHE密码套件在环回连接上失败握手?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ECDHE密码套件在环回连接上失败握手?相关的知识,希望对你有一定的参考价值。
我在Windows 7系统上使用Oracle Java 8(8u112)和JDK / JRE 8的'Java密码术扩展(JCE)无限强度管辖权策略文件'。为了提高我对安全套接字的理解,我正在尝试编写一个简单的程序,它在一个线程上打开一个服务器套接字,然后连接到这个套接字。
我想使用TLSv1.2和使用Java keytool生成的证书。我正在使用此问题的代码(SSLSocketFactoryEx):Which Cipher Suites to enable for SSL Socket?但我只指定了我想要使用的密码(这些也在this Oracle support page上提到):
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
TLS_EMPTY_RENEGOTIATION_INFO_SCSV
不幸的是,当我运行我的程序时,握手失败(请参阅下面的javax.debug.net = ssl输出)。如果我添加密码
TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
一切都按预期工作。似乎只有DHE_DSS(而不是ECDHE_ *)的密码才有效?有谁知道为什么以及如何解决它? JCE已经安装好了!
*** ClientHello, TLSv1.2
RandomCookie: GMT: 1469871576 bytes = { 114, 27, 128, 235, 21, 129, 252, 118, 108, 93, 245, 56, 159, 145, 94, 197, 161, 8, 37, 124, 4, 8, 58, 189, 102, 164, 83, 249 }
Session ID: {}
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, 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, SHA256withDSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
***
main, WRITE: TLSv1.2 Handshake, length = 139
server, READ: TLSv1.2 Handshake, length = 139
*** ClientHello, TLSv1.2
RandomCookie: GMT: 1469871576 bytes = { 114, 27, 128, 235, 21, 129, 252, 118, 108, 93, 245, 56, 159, 145, 94, 197, 161, 8, 37, 124, 4, 8, 58, 189, 102, 164, 83, 249 }
Session ID: {}
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, 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, SHA256withDSA, SHA1withECDSA, SHA1withRSA, SHA1withDSA
***
%% Initialized: [Session-1, SSL_NULL_WITH_NULL_NULL]
%% Invalidated: [Session-1, SSL_NULL_WITH_NULL_NULL]
server, SEND TLSv1.2 ALERT: fatal, description = handshake_failure
...
答案
事实证明我的证书是问题所在。要创建允许ECDHE的证书,您需要生成如下证书:
keytool -genkeypair -keystore localhostECDHE.jks -alias localhost -keyalg EC -keysize 256 -validity 30 -sigalg SHA512withECDSA
以上是关于ECDHE密码套件在环回连接上失败握手?的主要内容,如果未能解决你的问题,请参考以下文章
在 CertificateVerify 步骤之后,两种方式 SSL 握手失败 (javax.net.ssl.SSLHandshakeException),同时更改为新建立的密码套件