Guest User

Untitled

a guest
Jun 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import javax.net.ssl.HttpsURLConnection;
  2. import javax.net.ssl.SSLContext;
  3. import javax.net.ssl.TrustManager;
  4. import javax.net.ssl.X509TrustManager;
  5.  
  6. public class Main {
  7. public static void main(String[] args) throws Throwable {
  8. TrustManager[] trustAllCerts = new TrustManager[]{
  9. new X509TrustManager() {
  10. public java.security.cert.X509Certificate[] getAcceptedIssuers() {return null;}
  11. public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType){}
  12. public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType){}
  13. }
  14. };
  15.  
  16. SSLContext sc = SSLContext.getInstance("SSL");
  17. sc.init(null, trustAllCerts, new java.security.SecureRandom());
  18. HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
  19.  
  20. }
  21. }
Add Comment
Please, Sign In to add comment