1

I'm using a private CA certificate that is self-signed. I've imported the certificate to my Android device. I'm able to see it under Settings -> Security -> Trusted Credentials -> User.

I'm able to reach a website that is using the certificate signed by the CA. And I'm able to see the green padlock. But when I make HTTPS calls to the same URL from my android application, I'm getting Trust anchor for certification path not found.

I tried having my own SSL context for the HTTPS call, and I'm able to get 200 (Success). But I'm only allowed to use the default android trust store. If nothing works, then my final option will be going with the custom SSL context. So, I want to know for sure whether the default trust store way will work or not.

HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if(conn instanceof HttpsURLConnection && sslSocketFactory != null){
     ((HttpsURLConnection) conn).setSSLSocketFactory(sslSocketFactory);
}
int responseCode = conn.getResponseCode();

Any ideas to debug further would be helpful because I'm stuck on this for almost a week now.

Thanks.

Saravana Kumar
  • 140
  • 2
  • 16

0 Answers0