Created
November 21, 2017 03:06
-
-
Save toandv/254e483e13f1c1f377ad4c0b0f0c1d3a to your computer and use it in GitHub Desktop.
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
public static void trustSelfSignedSSL() { | |
try { | |
SSLContext ctx = SSLContext.getInstance("TLS"); | |
X509TrustManager tm = new X509TrustManager() { | |
public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException { | |
} | |
public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException { | |
} | |
public X509Certificate[] getAcceptedIssuers() { | |
return null; | |
} | |
}; | |
ctx.init(null, new TrustManager[]{tm}, null); | |
SSLContext.setDefault(ctx); | |
HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true); | |
} catch (Exception ex) { | |
LOG.error(ex.getMessage(), ex); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment