Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 340
GPGVM Avatar asked Aug 28 '17 16:08

GPGVM


People also ask

What is the meaning of Chain Validation Failed?

This error is coming from the SSL Handshake library, since the SDK is trying to call GET http request to https://sdk.split.io. A possible root cause is the device time is off the current time.


2 Answers

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

like image 193
WiseTap Avatar answered Sep 28 '22 21:09

WiseTap


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

like image 42
Caleb_Allen Avatar answered Sep 28 '22 21:09

Caleb_Allen