Setting https certificate trusted in Java

After digging a lot in web, I found the following snippet is useful in some scenarios, where we tries to connect to a HTTPS URL from our java code.  import java.io.BufferedReader;  import java.io.IOException;  import java.io.InputStreamReader;  import java.net.MalformedURLException;  import java.net.URL;  import java.net.URLConnection;  import java.security.KeyManagementException;  import java.security.NoSuchAlgorithmException;  import java.security.cert.CertificateException;  import java.security.cert.X509Certificate;    import javax.net.ssl.HostnameVerifier;  import javax.net.ssl.HttpsURLConnection;  import Read More…

[Solved] javax.net.ssl.sslhandshakeexception

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Sometime you might have received this kind of exception while running your application. The main reason behind this error is, the URL you are trying to access have no valid certificate issued from an authorized CA. In such cases Read More…