-
-
Save vadikgo/65360b846c93db9293f4204baf93e220 to your computer and use it in GitHub Desktop.
Disable SSL validation in Groovy
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
def nullTrustManager = [ | |
checkClientTrusted: { chain, authType -> }, | |
checkServerTrusted: { chain, authType -> }, | |
getAcceptedIssuers: { null } | |
] | |
def nullHostnameVerifier = [ | |
verify: { hostname, session -> true } | |
] | |
SSLContext sc = SSLContext.getInstance("SSL") | |
sc.init(null, [nullTrustManager as X509TrustManager] as TrustManager[], null) | |
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()) | |
HttpsURLConnection.setDefaultHostnameVerifier(nullHostnameVerifier as HostnameVerifier) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment