Friday, May 25, 2012

Avoiding the "javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed" error

Hey folks,

today I'm gonna share one solution for a problem related to https hand-shake.

The SSLHandshakeException is thrown by java when the host you are trying to contact doesn't have a valid SSL certificate for that hostname.
For example, when I wanted to connect to the site which certificate details look like  "This CA Root certificate is not trusted because it is not in the Trusted Root Certification Authorities store.

So when we are making a request to that site using java URLConnection it gives us an exception look like "javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed" . Then I did research for this problem and found a solution as follows: