Does wslite support ignoring SSL issues like HTTPBuilder
restagner opened this issue · comments
I was wondering if wslite supports ignoring of SSL Issues like HTTPBuilder. We currently have the following code that uses HTTPBuilder
static OauthToken getOauthToken(String username, String clientId, String clientSecret, String password) {
OauthToken oauthToken = new OauthToken()
try {
RESTClient client = new RESTClient(baseUrl)
client.ignoreSSLIssues()
def resp = client.post(
path: path,
requestContentType: "application/x-www-form-urlencoded",
contentType: "application/json",
body: [
client_id : clientId,
client_secret: clientSecret,
grant_type : grantType,
username : username,
password : password,
validator_id : validatorId,
scope : scope
]
)
oauthToken.accessToken = resp.data.access_token
oauthToken.refreshToken = resp.data.refresh_token
oauthToken.expiresIn = resp.data.expires_in
oauthToken.tokenType = resp.data.token_type
return oauthToken
} catch (Exception e) {
log.warn("Exception occured: ${e.message}")
}
log.warn("returning 'null'")
return null
}
If we remove the client.ignoreSSLIssues()
statement, we end up with an exception Exception in thread "main" javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated.
We want to move to using wslite, but before we do that, I was wondering if wsliite also supports this feature of ignoring SSL?
Yes, you can pass sslTrustAllCerts: true
to the various methods, for examples see https://github.com/jwagenleitner/groovy-wslite#trusting-all-ssl-certs-1.
Great!! Thanks for the prompt response.