Android Emulator “Chain Validation Failed” connecting developers machine with self-signed cert

和自甴很熟 提交于 2019-12-04 15:15:00

问题


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:

No reply because of error:

javax.net.ssl.SSLHandshakeException: Chain validation failed

at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:361)

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.

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?

I desire to be able to run my Android code and hit the developers box for testing / debugging etc.

I have read post like this one only to have the corporate environment I am in blocking the sites for open SSL etc.

https://android.stackexchange.com/questions/61540/self-signed-certificate-install-claims-success-but-android-acts-as-if-cert-isn

I am accessing the service through a WebView.


回答1:


A cause of this problem can be wrong date time of the device




回答2:


I was getting

javax.net.ssl.SSLHandshakeException: Chain validation failed

and

java.security.cert.CertPathValidatorException: Response is unreliable: its validity interval is out-of-date

the solution that worked for me was to force cold boot the emulator via Virtual Device Manager -> Actions dropdown -> Cold Boot Now




回答3:


Just restarting the Emulator solved this error. Long press the Power off button in the emulator menu and select Restart.




回答4:


I know this is an old Question, but I had a similar problem, with a completely different solution.

Make sure your SSL isn't expired. Once I fixed that problem I was no longer getting "javax.net.ssl.SSLHandshakeException: Chain validation failed" errors. I had other issues, but that's a different thread.

It sounds like such an obvious solution, but it's something to look into and not necessarily the first thing on people's mind.




回答5:


I wiped out all the data of the emulator and booted it up again, installed the app and everything was working. But seen other solution I think now that it might been an overkill.




回答6:


consider to use alternative internet connection when you got this issue

I've check time dan date, restarting my emulator, even my mac, apparently on my case

this error raised because I have shitty internet connection.

javax.net.ssl.SSLHandshakeException: Chain validation failed

extra: I think this exception need to be more explicit because it has so many triggers



来源:https://stackoverflow.com/questions/45923747/android-emulator-chain-validation-failed-connecting-developers-machine-with-se

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!