SSLHandshakeException尝试通过SSL连接到服务器

玫瑰

我正在尝试通过SSL向Java / Spring 4应用程序向远程服务器上的资源发出GET请求。说资源是:

https://remote-app/foo.pdf

我的应用程序使用https://github.com/square/okhttp作为HTTP客户端来执行该操作。

不幸的是,它在此资源上引发了异常。但是令人惊讶的是,它在通过其他服务器上的SSL公开的其他资源上获得了成功。

这是我得到的例外:

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) ~[na:1.8.0_51]
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:154) ~[na:1.8.0_51]
    at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2023) ~[na:1.8.0_51]
    at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1125) ~[na:1.8.0_51]
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) ~[na:1.8.0_51]
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) ~[na:1.8.0_51]
    at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387) ~[na:1.8.0_51]
    at com.squareup.okhttp.internal.http.SocketConnector.connectTls(SocketConnector.java:103) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.Connection.connect(Connection.java:143) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:185) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:128) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:341) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:330) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:248) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.Call.getResponse(Call.java:273) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201) ~[okhttp-2.4.0.jar!/:na]
    at com.squareup.okhttp.Call.execute(Call.java:81) ~[okhttp-2.4.0.jar!/:na]
    at com.org.package.util.Utils.getUrlResponse(MyUtils.java:54) ~[app-0.0.1-SNAPSHOT.jar!/:na]
    at com.org.package.service.impl.MyApp.uploadUrl(MyApp.java:303) [app.jar!/:na]
    at com.org.package.service.impl.MyApp.uploadResource(MyApp.java:135) [app.jar!/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [spring-tx-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at com.sun.proxy.$Proxy155.uploadR(Unknown Source) [na:na]
    at com.org.myprocess.receiveRequest(Processor.java:42) [app.jar!/:na]
    at com.org.myprocess$$FastClassBySpringCGLIB$$e05dc31.invoke(<generated>) [spring-core-4.1.7.RELEASE.jar!/:na]
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) [spring-core-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [spring-tx-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653) [spring-aop-4.1.7.RELEASE.jar!/:4.1.7.RELEASE]
    at com.org.myprocess$$EnhancerBySpringCGLIB$$d16a8116.receiveRequest(<generated>) [spring-core-4.1.7.RELEASE.jar!/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_51]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_51]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_51]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_51]
    at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:185) [spring-messaging-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
    at org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:104) [spring-messaging-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
    at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMatch(AbstractMethodMessageHandler.java:447) [spring-messaging-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
    at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessageInternal(AbstractMethodMessageHandler.java:408) [spring-messaging-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
    at org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.handleMessage(AbstractMethodMessageHandler.java:346) [spring-messaging-4.1.6.RELEASE.jar!/:4.1.6.RELEASE]
    at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer.executeMessage(SimpleMessageListenerContainer.java:160) [spring-cloud-aws-messaging-1.0.3.RELEASE.jar!/:1.0.3.RELEASE]
    at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer$MessageExecutor.run(SimpleMessageListenerContainer.java:226) [spring-cloud-aws-messaging-1.0.3.RELEASE.jar!/:1.0.3.RELEASE]
    at org.springframework.cloud.aws.messaging.listener.SimpleMessageListenerContainer$SignalExecutingRunnable.run(SimpleMessageListenerContainer.java:250) [spring-cloud-aws-messaging-1.0.3.RELEASE.jar!/:1.0.3.RELEASE]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_51]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_51]
    Suppressed: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
        ... 60 common frames omitted

我尝试从部署了我的应用程序的机器上卷曲:

curl -v https://www.remote-app/foo.pdf

回应>>>

 Trying 121.1.102.15...
    * Connected to www.remote-app (121.1.102.15) port 443 (#0)
    * Initializing NSS with certpath: sql:/etc/pki/nssdb
    *   CAfile: /etc/pki/tls/certs/ca-bundle.crt
      CApath: none
    * NSS error -12286 (SSL_ERROR_NO_CYPHER_OVERLAP)
    * Cannot communicate securely with peer: no common encryption algorithm(s).
    * Closing connection 0
    curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s).

但是后来我尝试通过使用密码算法,它可以工作:

curl -v --cipher ecdhe_rsa_aes_128_gcm_sha_256 https://www.remote-app/foo.pdf

回应>>>

Trying 121.1.102.15...
200 OK...
Content...
Content...

现在,我的问题是如何使我的应用程序连接到可能具有不同ssl配置的其他SSL服务器。因为该应用程序通过ssl而非大多数连接到大多数资源。

或者,我如何支持更多可用于不同服务器的密码套件?(假设这是正确的问题)

玫瑰

是的,所以我找到了解决方案。Java附带了某些默认情况下禁用的密码,而某些密码已启用。此处:https : //docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html令人惊讶的是,我上面提到的所有4个密码都在“默认启用”表中。但是在密码列表下面,他们提到了:

使用椭圆曲线密码术的密码套件(ECDSA,ECDH,ECDHE,ECDH_anon)需要满足以下要求的JCE密码提供程序:a ... b ... c ...

搜索JAVA JCE提供程序会将您带到http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

下载该zip文件,您将在local_policy.jar us_export_policy.jar中获得两个jar文件

将这两个jar文件放在ur jre jdk1.8.jdk / Contents / Home / jre / lib / security /中的安全文件夹中

干杯!

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何使用UnboundID SDK通过SSL服务器证书连接到LDAP服务器?

来自分类Dev

Moqui-通过SSL连接连接到IMAP服务器吗?

来自分类Dev

通过Unix终端连接到FTP服务器(通过TLS / SSL显式)

来自分类Dev

尝试连接到蓝牙服务器时连接被拒绝

来自分类Dev

通过SSL将Docker容器连接到公司LDAP服务器

来自分类Dev

通过SSL从PHP应用程序连接到Gearman服务器

来自分类Dev

通过socat连接到家庭服务器的SSL证书

来自分类Dev

无法使用Spring模板通过SSL连接到LDAP服务器

来自分类Dev

无法在Firefox 50上通过SSL连接到Jetty 9服务器

来自分类Dev

使用 alamofire 通过 iOS 应用程序连接到 Windows SSL 服务器

来自分类Dev

无法连接到服务器(通过远程连接)

来自分类Dev

尝试连接到服务器时算法协商失败

来自分类Dev

将 Java SSL 服务器连接到 Java SSL 服务器

来自分类Dev

通过android模拟器连接到服务器

来自分类Dev

通过android模拟器连接到服务器

来自分类Dev

无法连接到Indy SSL TCP服务器

来自分类Dev

使用 letencrypt ssl 连接到远程 RabbitMQ 服务器

来自分类Dev

连接超时与“全部尝试”之间的差异:“ 1”个地址,但无法通过HTTP连接到服务器

来自分类Dev

尝试使用Java连接https服务器时引发SSLHandshakeException

来自分类Dev

如何通过Docker连接到本地MySQL服务器?

来自分类Dev

如何通过SWI Prolog连接到MongoDB服务器?

来自分类Dev

外部通过SSH连接到Ubuntu服务器

来自分类Dev

通过代理服务器连接到MySQL

来自分类Dev

无法通过(IP或域名)连接到MySQL服务器

来自分类Dev

通过TomEE plus服务器连接到POJO?

来自分类Dev

无法通过代理连接到服务器

来自分类Dev

外部通过SSH连接到Ubuntu服务器

来自分类Dev

无法通过infiniband连接到服务器

来自分类Dev

如何通过代理服务器连接到VPN

Related 相关文章

  1. 1

    如何使用UnboundID SDK通过SSL服务器证书连接到LDAP服务器?

  2. 2

    Moqui-通过SSL连接连接到IMAP服务器吗?

  3. 3

    通过Unix终端连接到FTP服务器(通过TLS / SSL显式)

  4. 4

    尝试连接到蓝牙服务器时连接被拒绝

  5. 5

    通过SSL将Docker容器连接到公司LDAP服务器

  6. 6

    通过SSL从PHP应用程序连接到Gearman服务器

  7. 7

    通过socat连接到家庭服务器的SSL证书

  8. 8

    无法使用Spring模板通过SSL连接到LDAP服务器

  9. 9

    无法在Firefox 50上通过SSL连接到Jetty 9服务器

  10. 10

    使用 alamofire 通过 iOS 应用程序连接到 Windows SSL 服务器

  11. 11

    无法连接到服务器(通过远程连接)

  12. 12

    尝试连接到服务器时算法协商失败

  13. 13

    将 Java SSL 服务器连接到 Java SSL 服务器

  14. 14

    通过android模拟器连接到服务器

  15. 15

    通过android模拟器连接到服务器

  16. 16

    无法连接到Indy SSL TCP服务器

  17. 17

    使用 letencrypt ssl 连接到远程 RabbitMQ 服务器

  18. 18

    连接超时与“全部尝试”之间的差异:“ 1”个地址,但无法通过HTTP连接到服务器

  19. 19

    尝试使用Java连接https服务器时引发SSLHandshakeException

  20. 20

    如何通过Docker连接到本地MySQL服务器?

  21. 21

    如何通过SWI Prolog连接到MongoDB服务器?

  22. 22

    外部通过SSH连接到Ubuntu服务器

  23. 23

    通过代理服务器连接到MySQL

  24. 24

    无法通过(IP或域名)连接到MySQL服务器

  25. 25

    通过TomEE plus服务器连接到POJO?

  26. 26

    无法通过代理连接到服务器

  27. 27

    外部通过SSH连接到Ubuntu服务器

  28. 28

    无法通过infiniband连接到服务器

  29. 29

    如何通过代理服务器连接到VPN

热门标签

归档