问题描述
我有一个调用基于 Web 的 API 服务的 Android Studio 项目.当服务代码在 dev、qa、prod 等中时.没有证书问题,但是当尝试点击 web api 开发人员框以测试新功能/错误修复/等时.我得到:
I have an Android Studio project that calls a web based API service. When the service code is in dev, qa, prod etc. There are NO certificate issues but when trying to hit the web api developers box to test a new feature / bug fix / etc. I get:
因为错误没有回复:
javax.net.ssl.SSLHandshakeException:链验证失败
javax.net.ssl.SSLHandshakeException: Chain validation failed
在 com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)
at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)
我有从服务开发人员机器导出的自签名证书,没有私钥 DER 编码.我掉到模拟器上,它安装"了.但这不起作用.
I had the self signed certificate exported from the service developers machine WITHOUT the private key DER encoded. I dropped onto the emulator and it "installed" but this did not work.
我将上面的相同证书复制到模拟的 sd 卡上.然后从模拟器中的安全设置安装.结果相同.链验证失败.
I took the same cert above and copied to the emulated sd card. Then installed from security settings in emulator. Same result. Chain validation failed.
现在我的安全/证书知识非常基础.我认为错误实际上描述了问题.自签名证书中没有链......但我可能是错的.
Now my security / certificate knowledge is very basic. I think the error actually describes the problem. There is no chain in a self signed certificate...but I could be wrong.
无论如何,我该如何解决这个问题?
Regardless, how do I work around this?
我希望能够运行我的 Android 代码并点击开发人员框进行测试/调试等.
I desire to be able to run my Android code and hit the developers box for testing / debugging etc.
我读过这样的帖子只是为了让我的公司环境阻止开放 SSL 等网站.
I have read post like this one only to have the corporate environment I am in blocking the sites for open SSL etc.
我正在通过 WebView 访问服务.
I am accessing the service through a WebView.
推荐答案
这个问题的原因可能是设备的日期时间错误
A cause of this problem can be wrong date time of the device
这篇关于Android 模拟器“链验证失败"将开发人员机器与自签名证书连接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!