Skip to content

Instantly share code, notes, and snippets.

@joshkitt
Created November 20, 2014 16:35
Show Gist options
  • Save joshkitt/da85e11e443a43bb7c37 to your computer and use it in GitHub Desktop.
Save joshkitt/da85e11e443a43bb7c37 to your computer and use it in GitHub Desktop.
Java - Ignore SSL Certificate
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