Created
November 20, 2014 16:35
-
-
Save joshkitt/da85e11e443a43bb7c37 to your computer and use it in GitHub Desktop.
Java - Ignore SSL Certificate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try { | |
SSLContext ctx = SSLContext.getInstance("SSL"); | |
X509TrustManager tm = new X509TrustManager() { | |
@Override | |
public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { | |
} | |
@Override | |
public void checkServerTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { | |
} | |
@Override | |
public X509Certificate[] getAcceptedIssuers() { | |
return new X509Certificate[0]; | |
} | |
}; | |
ctx.init(null, new TrustManager[] { tm }, null); | |
HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory()); | |
} catch (Exception ignored) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment