How to resolve SSLHandshakeException

When ever I try to build my Gradle project i am getting SSLHandshakeException. I have tried with many Gradle builds/versions. I have also added the certificate to cacerts

Exception in thread “main” PKIX path building failed: unable to find valid certification path to requested target

This error indicates the certificate presented by the server is not trusted. It is possible some other entity is responding to you instead of When I use a web browser to open, I can see a valid certificate. You should try the same.

This could happen if you are connected to some public wifi that intercepts all traffic until you login or accept some user agreement.