Skip to content
Advertisement

SSLHandshakeException Trust anchor for certification path not found Android HTTPS

I’m trying to establish a connection to a HTTPS site and I got this exception: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
My original code is as follows:

JavaScript

Then, I read Google’s article here and modified my code to:

JavaScript

Regarding the R.raw.cert file, I use this site to check the certificates of the site. I found 3 cetificates and I have no idea which one to use. I tried them one by one.
The one name “VeriSign Class 3 Public Primary Certification Authority – G5” results in the following exceptions:

JavaScript

When I use the one named “VeriSign Class 3 Secure Server CA – G3” or the one with the name “example.com” (same as the site name) I got the same SSLHandshakeException.

What do I need to do?

At the same time, Symatec SSL Toolbox shows me an error and 1 recommendation which I don’t understand:

JavaScript

The 3 certificates found for the site are as follows:
example.com:

JavaScript

VeriSign Class 3 Secure Server CA – G3

JavaScript

VeriSign Class 3 Public Primary Certification Authority – G5:

JavaScript

Advertisement

Answer

Updates:

  • I’ve never been an expert at this matter, the following is only a workaround and might not be secure, use it at your own risk
  • This post is 3+ years old, so it may be outdated by now (code will not compile) but you should find be able to find the updated approach or official docs saying certain parts are deprecated or removed

Thank noloader for pointing me in the correction direction. I solved my issue using the following:

JavaScript

Out of the 3 certificates found for the site, mentioned in my question, the one that worked for me was the VeriSign Class 3 Secure Server CA – G3

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement