Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用TLSv1.2的Apache HttpClient握手失败_Java_Ssl_Wso2_Wso2esb - Fatal编程技术网

Java 使用TLSv1.2的Apache HttpClient握手失败

Java 使用TLSv1.2的Apache HttpClient握手失败,java,ssl,wso2,wso2esb,Java,Ssl,Wso2,Wso2esb,首先,我将解释这个场景 我有一个WSO2 ESB-4.6.0(使用Apache的HttpClient)运行于jdk1.7.079,我的目标是调用一个只接受TLSv1.2协议的外部安全服务,而不将Java更新到版本8。 外部服务器指令包括: Supported versions: TLSv1.2 Deflate compression: no Supported cipher suites (ORDER IS NOT SIGNIFICANT): TLSv1.2 RSA_WITH_3D

首先,我将解释这个场景

我有一个WSO2 ESB-4.6.0(使用Apache的HttpClient)运行于
jdk1.7.079
,我的目标是调用一个只接受
TLSv1.2
协议的外部安全服务,而不将Java更新到版本8。
外部服务器指令包括:

Supported versions: TLSv1.2
Deflate compression: no
Supported cipher suites (ORDER IS NOT SIGNIFICANT):
  TLSv1.2
     RSA_WITH_3DES_EDE_CBC_SHA
     DHE_RSA_WITH_3DES_EDE_CBC_SHA
     RSA_WITH_AES_128_CBC_SHA
     DHE_RSA_WITH_AES_128_CBC_SHA
     RSA_WITH_AES_256_CBC_SHA
     DHE_RSA_WITH_AES_256_CBC_SHA
     RSA_WITH_AES_128_CBC_SHA256
     RSA_WITH_AES_256_CBC_SHA256
     RSA_WITH_CAMELLIA_128_CBC_SHA
     DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
     DHE_RSA_WITH_AES_128_CBC_SHA256
     DHE_RSA_WITH_AES_256_CBC_SHA256
     RSA_WITH_CAMELLIA_256_CBC_SHA
     DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
     TLS_RSA_WITH_AES_128_GCM_SHA256
     TLS_RSA_WITH_AES_256_GCM_SHA384
     TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
     TLS_DHE_RSA_WITH_AES_256_GCM_SHA384
     TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
     TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
     TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
     TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
     TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
     TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
     TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
----------------------
Minimal encryption strength:     strong encryption (96-bit or more)
Achievable encryption strength:  strong encryption (96-bit or more)
BEAST status: protected
CRIME status: protected
因此,构建并调用一个简单的代理(该代理具有指向此服务的端点),将导致:

Using SSLEngineImpl.
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
HTTPS-Sender I/O dispatcher-1, fatal error: 40: Couldn't kickstart handshaking
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
HTTPS-Sender I/O dispatcher-1, SEND TLSv1 ALERT:  fatal, description = handshake_failure
HTTPS-Sender I/O dispatcher-1, WRITE: TLSv1 Alert, length = 2
[2016-02-25 22:15:12,689] ERROR - TargetHandler I/O error: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
        at sun.security.ssl.Handshaker.activate(Handshaker.java:470)
        at sun.security.ssl.SSLEngineImpl.kickstartHandshake(SSLEngineImpl.java:714)
        at sun.security.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java:740)
        at org.apache.http.impl.nio.reactor.SSLIOSession.bind(SSLIOSession.java:141)
        at org.apache.http.impl.nio.ssl.SSLClientIOEventDispatch.connected(SSLClientIOEventDispatch.java:205)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.sessionCreated(BaseIOReactor.java:250)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.processNewChannels(AbstractIOReactor.java:425)
        at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:289)
        at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
        at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:542)
        at java.lang.Thread.run(Thread.java:745)
在这一点上,我的第一个想法是找到一种方法来“配置”Java7以使用它。因此,我确实使用Eclipse(使用
javax.xml.soap.SOAPConnectionFactory
)构建了一个简单的webservice客户机类,并使用ESB使用的相同JVM运行它。正如所料,同样的错误
但是,我编辑了
jre/lib/security/java.security
文件,找到了使调用工作的以下参数:

java MyClientClass -Dhttps.protocols=TLSv1.2 -Dhttps.cipherSuites=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
在所有这些之后,我认为应用于ESB的相同参数应该可以工作。但是上面的两个参数和下面的其他参数,在许多不同的组合中,并没有实现这一点,与以前有相同的例外

./wso2server.sh -Ddeployment.security.SSLv3=false \
                -Ddeployment.security.TLSv1=false \
                -Ddeployment.security.TLSv1.1=false \
                -Ddeployment.security.TLSv1.2=true \
                -Dhttps.protocols=TLSv1.2 \
                -Dhttps.cipherSuites=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
为什么具有相同JVM和相同参数的ESB不工作,而
MyClientClass
?问题出在Apache的http核心实现中(作为堆栈跟踪点)?我犯了一些错误,还是忽略了这些参数


HttpCore版本是4.1.3。

HttpsUrlConnection使用了
HttpsUrlConnection
https.protocols
属性,但从stacktrace看,ESB代码使用的是Apache的
HttpClient
(它不遵守
https.protocols
);有关讨论,请参阅本文:我明白了。因此,Apache客户端的“替代方案”仍然未知。使用Java7,是的。如果您可以升级到Java 8,那么您将能够使用“jdk.tls.client.protocols”系统属性。我已经用Java 8进行了测试,它可以工作,但它也会导致ESB的其他组件出现问题。这已被确定为错误[1],并在ESB 4.9.0中得到修复。请与wso2支持团队联系,他们可能有ESB 4.6.0的修补程序。或者尝试升级到Java8,并在java.security中设置以下jdk.tls.client.protocols=TLSv1.2。[1]