Apache HttpClient中的自签名证书问题

贝尤拉·泽纳洛夫(Beydulla Zeynalov)

我有一个网站的自签名证书。我使用keytool将其导入到java cacert文件中。之后,它可以很好地与RestTemplate请求一起使用。当我使用Apache HttpClients请求时,出现如下异常:

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:275)
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:254)
    at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:123)
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:318)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:363)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:219)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:86)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
    at HttpClientRequestTest.test3(HttpClientRequestTest.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: java.io.EOFException: SSL peer shut down incorrectly

RestTemplate代码:

final RestTemplate restTemplate = new RestTemplate();
final ResponseEntity<String> response = restTemplate.getForEntity(url, String.class);

Apache HttpClients示例:

final HttpGet request = new HttpGet(url);
final HttpClient httpClient = HttpClients.createDefault();
final HttpResponse response = httpClient.execute(request);

有谁知道为什么它与RestTemplate一起使用而不与HttpClients一起使用?
HttpClient版本为4.5.13

迈克·罗宾逊

在处理“ any(!)类的“加密问题”时”,您需要查看日志文件,尤其是“从服务器端”。

当然,“客户”绝对是故意的,“应该绝对学不到任何东西”,因为它被认为是“夏娃入侵者”,而不是“爱丽丝”或“鲍勃”。客户只感觉到门被猛地关上了,完全没有任何解释。

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

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

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

信任自签名证书的任何Apache HttpClient 4.4示例

来自分类Dev

Apache httpclient 4.3.3如何仅接受一个特定的自签名证书

来自分类常见问题

忽略Apache HttpClient 4.3中的SSL证书

来自分类Dev

生成自签名证书后,Apache无法启动

来自分类Dev

使用Apache-Commons-net添加自签名SSL证书

来自分类Dev

SSL证书问题:证书链中的自签名证书

来自分类Dev

只信任我在httpclient中的自签名证书

来自分类Dev

具有自签名SSL证书的Apache camel http4

来自分类Dev

具有自签名证书的Apache 2.4始终重定向到默认虚拟主机

来自分类Dev

使用sudo在ubuntu上创建了自签名的openssl证书,现在apache无法识别

来自分类Dev

Azure DEVOPS中的GIT错误-SSL证书问题:证书链中的自签名证书

来自分类Dev

卷曲错误60,SSL证书问题:证书链中的自签名证书

来自分类Dev

Android中的自签名证书

来自分类Dev

RCurl和自签名证书问题

来自分类Dev

让IDE添加自签名证书后,多个程序中的SSL证书问题

来自分类Dev

Apache的问题

来自分类Dev

作者的主签名的时间戳发现了一个链构建问题:UntrustedRoot:证书链中的自签名证书

来自分类Dev

忽略提取中的自签名SSL证书

来自分类Dev

信任Codenameone的ConnectionRequest中的自签名证书

来自分类Dev

Apache2 在使用自签名证书时尝试使用 .htaccess 文件强制客户端使用 HTTPS 时出现内部 500 错误

来自分类Dev

Docker中Apache的权限问题

来自分类Dev

Apache OpenNLP中的日期问题

来自分类Dev

Apache错误日志中的问题?

来自分类Dev

Apache异步HttpClient不快

来自分类Dev

Apache HttpClient Android(Gradle)

来自分类Dev

Apache HTTPClient超时随时

来自分类Dev

计算对 apache HttpClient 的调用

来自分类Dev

Apache HttpClient 进程 HttpResponse

来自分类Dev

信任自签名证书时Android应用SSL问题

Related 相关文章

  1. 1

    信任自签名证书的任何Apache HttpClient 4.4示例

  2. 2

    Apache httpclient 4.3.3如何仅接受一个特定的自签名证书

  3. 3

    忽略Apache HttpClient 4.3中的SSL证书

  4. 4

    生成自签名证书后,Apache无法启动

  5. 5

    使用Apache-Commons-net添加自签名SSL证书

  6. 6

    SSL证书问题:证书链中的自签名证书

  7. 7

    只信任我在httpclient中的自签名证书

  8. 8

    具有自签名SSL证书的Apache camel http4

  9. 9

    具有自签名证书的Apache 2.4始终重定向到默认虚拟主机

  10. 10

    使用sudo在ubuntu上创建了自签名的openssl证书,现在apache无法识别

  11. 11

    Azure DEVOPS中的GIT错误-SSL证书问题:证书链中的自签名证书

  12. 12

    卷曲错误60,SSL证书问题:证书链中的自签名证书

  13. 13

    Android中的自签名证书

  14. 14

    RCurl和自签名证书问题

  15. 15

    让IDE添加自签名证书后,多个程序中的SSL证书问题

  16. 16

    Apache的问题

  17. 17

    作者的主签名的时间戳发现了一个链构建问题:UntrustedRoot:证书链中的自签名证书

  18. 18

    忽略提取中的自签名SSL证书

  19. 19

    信任Codenameone的ConnectionRequest中的自签名证书

  20. 20

    Apache2 在使用自签名证书时尝试使用 .htaccess 文件强制客户端使用 HTTPS 时出现内部 500 错误

  21. 21

    Docker中Apache的权限问题

  22. 22

    Apache OpenNLP中的日期问题

  23. 23

    Apache错误日志中的问题?

  24. 24

    Apache异步HttpClient不快

  25. 25

    Apache HttpClient Android(Gradle)

  26. 26

    Apache HTTPClient超时随时

  27. 27

    计算对 apache HttpClient 的调用

  28. 28

    Apache HttpClient 进程 HttpResponse

  29. 29

    信任自签名证书时Android应用SSL问题

热门标签

归档