SSLPeerUnverifiedException: "peer not authenticated" when using groovy RestClient with ignoreSSLIssues ()

I am writing an integration test for my rest destination, and I chose groovy RestClient. My challenge was relaxing on "https" and I began to encounter SSL exceptions. While I was delving into this more, I was glad to learn about the ignoreSSLIssues () method ( http://groovy.codehaus.org/modules/http-builder/doc/ssl.html ). Since this is available in HttpBuilder version 0.7.1, I updated this bank and some dependent banks. So with this in place, according to the document, I was hoping the code below would work -

def httpBuilder = new HTTPBuilder('baseurl')
httpBuilder.ignoreSSLIssues()
def resp = httpBuilder.get(path : 'restPath')
println resp

But it still throws javax.net.ssl.SSLPeerUnverifiedException: peer is not authenticated.

Any help on this is appreciated.

Thank.

+4
source share
1 answer

Just ran into this problem. You also get this fraudulent error if you use an outgoing proxy server and have not configured the HTTPBuilder class to use it explicitly.

You need to set setProxy () method for HTTPBuilder. For some reason, OPTS JVMs such as -Dhttp.proxyHost do not seem to comply with HTTPBuilder. My version looks something like this:

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.HEAD

def http = new HTTPBuilder( 'https://www.dev.java.net/' )

http.setProxy("my.proxy.com", 8080, "http")
http.ignoreSSLIssues()

def status = http.request( HEAD ) {
    response.success = { it.status }
}
0
source

All Articles