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…