如何调试ssl连接错误 [英] How to debug the ssl connection error

查看:1486
本文介绍了如何调试ssl连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说明:
我尝试将一些xml格式数据发布到API网关。当我使用JAVA HttpsURLConnection在Https协议下将数据发布到一个站点时,我收到了收到的致命警报:handshake_failure 错误。

尝试
1:使用vm选项启用SSL调试,添加 -Djavax.net.debug = all
然后我得到了:

Attempts 1: enable the SSL debug with vm option by adding -Djavax.net.debug=all then i got those:

Ignoring unavailable cipher suite: TLS_DHE_DSS_WITH_AES_256_GCM_SHA384
Ignoring unavailable cipher suite: TLS_RSA_WITH_AES_256_CBC_SHA
Ignoring unavailable cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
Allow unsafe renegotiation: false
Allow legacy hello messages: true
Is initial handshake: true
Is secure renegotiation: false
Ignoring unsupported cipher suite: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 for TLSv1
Ignoring unsupported cipher suite: TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 for TLSv1.1
%% No cached client session
*** ClientHello, TLSv1.2
RandomCookie:  GMT: 1511946801 bytes = { 126, 217, 71, 253, 228, 128, 168, 241, 225, 17, 188, 15, 91, 241, 195, 104, 187, 74, 19, 124, 157, 248, 96, 131, 84, 231, 109, 219 }
Session ID:  {}
Cipher Suites: [TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, 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_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, 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: [type=host_name (0), value=alipay-test.connectedpos.de]
***
[write] MD5 and SHA1 hashes:  len = 243
0000: 01 00 00 EF 03 03 5A 1E   7A 31 7E D9 47 FD E4 80  ......Z.z1..G...
0010: A8 F1 E1 11 BC 0F 5B F1   C3 68 BB 4A 13 7C 9D F8  ......[..h.J....
0020: 60 83 54 E7 6D DB 00 00   46 C0 23 C0 27 00 3C C0  `.T.m...F.#.'.<.
0030: 25 C0 29 00 67 00 40 C0   09 C0 13 00 2F C0 04 C0  %.).g.@...../...
0040: 0E 00 33 00 32 C0 2B C0   2F 00 9C C0 2D C0 31 00  ..3.2.+./...-.1.
0050: 9E 00 A2 C0 08 C0 12 00   0A C0 03 C0 0D 00 16 00  ................
0060: 13 C0 07 C0 11 00 05 C0   02 C0 0C 00 04 00 FF 01  ................
0070: 00 00 80 00 0A 00 34 00   32 00 17 00 01 00 03 00  ......4.2.......
0080: 13 00 15 00 06 00 07 00   09 00 0A 00 18 00 0B 00  ................
0090: 0C 00 19 00 0D 00 0E 00   0F 00 10 00 11 00 02 00  ................
00A0: 12 00 04 00 05 00 14 00   08 00 16 00 0B 00 02 01  ................
00B0: 00 00 0D 00 1A 00 18 06   03 06 01 05 03 05 01 04  ................
00C0: 03 04 01 03 03 03 01 02   03 02 01 02 02 01 01 00  ................
00D0: 00 00 20 00 1E 00 00 1B   61 6C 69 70 61 79 2D 74  .. .....alipay-t
00E0: 65 73 74 2E 63 6F 6E 6E   65 63 74 65 64 70 6F 73  est.connectedpos
00F0: 2E 64 65                                           .de
main, WRITE: TLSv1.2 Handshake, length = 243
[Raw write]: length = 248
0000: 16 03 03 00 F3 01 00 00   EF 03 03 5A 1E 7A 31 7E  ...........Z.z1.
0010: D9 47 FD E4 80 A8 F1 E1   11 BC 0F 5B F1 C3 68 BB  .G.........[..h.
0020: 4A 13 7C 9D F8 60 83 54   E7 6D DB 00 00 46 C0 23  J....`.T.m...F.#
0030: C0 27 00 3C C0 25 C0 29   00 67 00 40 C0 09 C0 13  .'.<.%.).g.@....
0040: 00 2F C0 04 C0 0E 00 33   00 32 C0 2B C0 2F 00 9C  ./.....3.2.+./..
0050: C0 2D C0 31 00 9E 00 A2   C0 08 C0 12 00 0A C0 03  .-.1............
0060: C0 0D 00 16 00 13 C0 07   C0 11 00 05 C0 02 C0 0C  ................
0070: 00 04 00 FF 01 00 00 80   00 0A 00 34 00 32 00 17  ...........4.2..
0080: 00 01 00 03 00 13 00 15   00 06 00 07 00 09 00 0A  ................
0090: 00 18 00 0B 00 0C 00 19   00 0D 00 0E 00 0F 00 10  ................
00A0: 00 11 00 02 00 12 00 04   00 05 00 14 00 08 00 16  ................
00B0: 00 0B 00 02 01 00 00 0D   00 1A 00 18 06 03 06 01  ................
00C0: 05 03 05 01 04 03 04 01   03 03 03 01 02 03 02 01  ................
00D0: 02 02 01 01 00 00 00 20   00 1E 00 00 1B 61 6C 69  ....... .....ali
00E0: 70 61 79 2D 74 65 73 74   2E 63 6F 6E 6E 65 63 74  pay-test.connect
00F0: 65 64 70 6F 73 2E 64 65                            edpos.de
[Raw read]: length = 5
0000: 15 03 03 00 02                                     .....
[Raw read]: length = 2
0000: 02 28                                              .(
main, READ: TLSv1.2 Alert, length = 2
main, RECV TLSv1.2 ALERT:  fatal, handshake_failure
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

尝试
2:试过这个解决方案,但没有区别。 SSLHandshakeException:收到致命警报:Java 6之后的handshake_failure - > ; 8升级

@AxelH评论:

我做拥有正常证书,互联网上的任何人都可以公开访问https(这就是SSL证书的工作方式)。

I do have "normal" certificate, the https should be public accessible for anyone in Internet(That's how SSL certificate works).

➜  security ls -l
total 280
-rw-rw-r--  1 root  wheel      0 Sep 18  2014 trusted.libraries
-rw-rw-r--  1 root  wheel  20969 Sep 18  2014 java.security
-rw-rw-r--  1 root  wheel   2466 Sep 18  2014 java.policy
-rw-rw-r--  1 root  wheel  95881 Sep 18  2014 cacerts
-rw-rw-r--  1 root  wheel   1188 Sep 18  2014 blacklisted.certs
-rw-rw-r--  1 root  wheel   3890 Sep 18  2014 blacklist

链接:

https ://blogs.oracle.com/java-platform-group/diagnosing-tls,-ssl,-and-https
https://tonyyan.wordpress.com/2015/07/17 / enabled-tls-1-2-and-tls-1-1-on-java-7 /

推荐答案

您尝试连接的网站( alipay-test.connectedpos.de )没有任何与Java共同的密码套件

The site you're attempting to connect (alipay-test.connectedpos.de) does not have any cipher suites in common with Java.

TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030)
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (0xc028)
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)
TLS_RSA_WITH_AES_256_GCM_SHA384 (0x9d)
TLS_RSA_WITH_AES_256_CBC_SHA256 (0x3d)
TLS_RSA_WITH_AES_256_CBC_SHA (0x35)
TLS_RSA_WITH_CAMELLIA_256_CBC_SHA (0x84)

您需要启用Java的JCE无限强度管辖权政策才能实现此目的。

You will need to enable the JCE Unlimited Strength Jurisdiction Policy for Java for this to work.

对于Java 7,您可以从 http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html 。对于除Update 151之外的所有Java 8版本,您可以从 http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html 。完成后,将JRE的lib / security目录下的两个JAR(local_policy.jar,US_export_policy.jar)替换为下载的包中的JAR。

For Java 7, you can download the JCE Unlimited Strength Jurisdiction Policy files from http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html. For all versions of Java 8 except Update 151, you can download the files from http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html. Once done, replace the two JARs (local_policy.jar, US_export_policy.jar) under your JRE's lib/security directory with the ones from the downloaded package.

For Java 8 Update 151及更高版本,默认安装文件。要启用这些文件,请编辑JRE的lib / security目录下的java.security文件,并指定 crypto.policy = unlimited

For Java 8 Update 151 and later, the files are installed by default. To enable these file, edit the file java.security under your JRE's lib/security directory and specify crypto.policy=unlimited.

这将添加额外的(更强大的)密码套件,您应该能够连接而无需对代码进行任何更改或启用TLSv1.2

This will add additional (stronger) ciphersuites and you should be able to connect without having to make any changes to your code or enable TLSv1.2

这篇关于如何调试ssl连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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