daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.net.URL;
  2. import java.security.SecureRandom;
  3. import java.security.cert.CertificateException;
  4. import java.security.cert.X509Certificate;
  5. import javax.net.ssl.KeyManager;
  6. import javax.net.ssl.SSLContext;
  7. import javax.net.ssl.SSLSession;
  8. import javax.net.ssl.TrustManager;
  9. import javax.net.ssl.X509TrustManager;
  10.  
  11. public class Useless {
  12.  
  13.     public static void breakSSL() throws Exception {
  14.         SSLContext ctx = SSLContext.getInstance("TLS");
  15.         ctx.init(new KeyManager[0], new TrustManager[] {new DefaultTrustManager()}, new SecureRandom());
  16.         SSLContext.setDefault(ctx);
  17.     }
  18.     /* make a trustmanager that doesn't actually do any trust management */
  19.     private static class DefaultTrustManager implements X509TrustManager {
  20.  
  21.         @Override
  22.         public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
  23.  
  24.         @Override
  25.         public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {}
  26.  
  27.         @Override
  28.         public X509Certificate[] getAcceptedIssuers() {
  29.             return null;
  30.         }
  31.     }
  32. }
RAW Paste Data
Top