-
-
Save ctkdev/bd8630d4e7aeb1143e05ac7a1692ad89 to your computer and use it in GitHub Desktop.
Ignore SSL certs in groovy
This file contains hidden or 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 | |
| hostname.startsWith('yuml.me') | |
| } | |
| ] | |
| javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL") | |
| sc.init(null, [nullTrustManager as javax.net.ssl.X509TrustManager] as javax.net.ssl.X509TrustManager[], null) | |
| javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()) | |
| javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(nullHostnameVerifier as javax.net.ssl.HostnameVerifier) | |
| def url = new URL('https://mysecureserver') | |
| url.openStream() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment