和第三方对接,遇到点问题,求大佬解惑

2020-07-15 14:12:42 +08:00
 Evilk

现在的情况:

1.Java 那边,通知我们后端(PHP)处理结果,但他们那边一直报错

java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

2.尝试过的方法:

(1).他们在他们的服务器上,curl 我们的 URL,成功

(2).用 postman,访问我们的 URL,成功

(3).直接通过浏览器访问我们的 URL,成功

之前怀疑是 TLS 版本问题 后来检查了我们的服务器,同时支持 TLS-1.2 & TLS-1.3 & HTTP/2

现在的问题:

对方找不到原因,让我们检查 问题是,其他方式都能成功, 只是他们通过 Java 程序,直接通知我们,就报错

有人遇到过这种情况吗?

3365 次点击
所在节点    PHP
30 条回复
Evilk
2020-07-15 16:43:38 +08:00
这是我们服务器 curl 对方的返回:


* About to connect() to xxx port 443 (#0)
* Trying xxx...
* Connected to xxx (xxx) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* Server certificate:
* subject: O=Internet Widgits Pty Ltd,ST=Some-State,C=AU
* start date: 7 月 22 06:02:24 2016 GMT
* expire date: 8 月 21 06:02:24 2016 GMT
* common name: (nil)
* issuer: O=Internet Widgits Pty Ltd,ST=Some-State,C=AU
* NSS error -8181 (SEC_ERROR_EXPIRED_CERTIFICATE)
* Peer's Certificate has expired.
* Closing connection 0
curl: (60) Peer's Certificate has expired.
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.


这代表什么意思?
dilu
2020-07-15 16:49:15 +08:00
@Evilk #15 抱歉看错了 原来是对方访问你们报错啊

那让对方用 strace 看一下系统调用
qq1340691923
2020-07-15 17:14:03 +08:00
都统一下,换成 java
Evilk
2020-07-15 17:18:23 +08:00
现在对方服软了
在让检查他们服务器的根证书,怀疑是过期或者无效
所以 HTTPS 握手失败
qwerthhusn
2020-07-15 19:31:49 +08:00
@Evilk 不是 1.8,可能是高于 1.8,那肯定支持 TLS1.2 的;如果是以下的话,jdk7 支持 1.2 但是需要手动在程序配置中开启,jdk6 就很老肯定不支持 1.2 了

还有一种方式,抓包放 wireshark 看,Client Hello 报文,很容易就看出来客户端支持的版本

除了版本问题,还有可能是 CA 不被认的问题,楼上很多都给了检测方式。。。
sampeng
2020-07-15 22:25:02 +08:00
现在程序员都不认识英文么…
SEC_ERROR_EXPIRED_CERTIFICATE)
* Peer's Certificate has expired.
sampeng
2020-07-15 22:26:02 +08:00
这还用怀疑?证书有效时间是 2016 年
Evilk
2020-07-16 16:11:47 +08:00
@qwerthhusn 现在应该不是 TLS 版本问题
应该是我们服务器要求的

Cipher : ECDHE-ECDSA-CHACHA20-POLY1305

对方 Java 不支持,目前对方还在找原因
Evilk
2020-07-16 16:15:48 +08:00
而且对方的证书,是自己签的,不是通过 CA 来的
访问我们的时候,我们认为证书无效,所以拒绝了对方的 HTTPS 握手请求
qwerthhusn
2020-07-16 17:39:15 +08:00
@Evilk 为啥会要求 CHACHA20-POLY1305 这套???
以前 AES 在移动设备上比较慢,google 弄出来一个 CHACHA20,比 AES 快一点
后来 ARM 指令集有了 AES-NI,即硬件计算 AES,现在主流的又变回 AES 了
而且一般 TLS Server 应该设置成同时支持 AES 和 CHACHA 的。。

对方的证书?? Server 要求客户端 SSL 认证?不要求的话,客户端传什么证书。。。。。要求的话,是服务端指定验证客户端证书的 CA 的。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/690223

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX