Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails:Groovy:SSLPeerUnverifiedException: peer not authenticated

I want to hit an xml request to a url while running the code in my local system it is working well i have created a war file and deployed the same in server,but while running in server getting an exception 'javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated' i have used groovy http builder

def http = new HTTPBuilder(url)
          http.auth.basic('username', 'password')
        try {               
            http.request(Method.POST, ContentType.TEXT) {
                        req->
                            headers.accept = "application/xml"
                            body = request //xml request
                            response.success = {
                                        resp,reader ->
                                            Response =  reader.text
                            }
            }
        }
        catch(HttpResponseException ex) {
             println ex;
        }

how can i solve this problem in this case..?

like image 899
Antony Prince Avatar asked May 16 '14 04:05

Antony Prince


1 Answers

Workaround: The following answer provides a workaround for this issue: https://stackoverflow.com/a/25076888/782034

Just found out that new version (0.7.1) of HttpBuilder introduces method:

ignoreSSLIssues()

This solves all problems regarding invalid SSL certificates (of course you have to be aware that it also decrease security).

More information about this method: http://groovy.codehaus.org/modules/http-builder/doc/ssl.html (section at the bottom)

i.e.

def http = new HTTPBuilder(url)
http.ignoreSSLIssues()

Solution: If you want to do things the 'proper' way, checkout the other solutions regarding importing the server's certificates. e.g. SSLPeerUnverifiedException: peer not authenticated

like image 197
Nick Grealy Avatar answered Sep 30 '22 07:09

Nick Grealy