2014-05-16 13 views
5

Voglio inviare una richiesta xml a un URL durante l'esecuzione del codice nel mio sistema locale funziona correttamente ho creato un file war e distribuito lo stesso nel server, ma durante l'esecuzione nel server di ottenere un'eccezione 'javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated' ho usato costruttore http GroovyGrails: Groovy: SSLPeerUnverifiedException: peer non autenticato

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; 
     } 

come posso risolvere questo problema in questo caso ..?

+0

Prova [questo blog] (http: //blog.nerdability.com/2013/01/tech-how-to-fix-sslpeerunverifiedexcept.html) e i seguenti link che hanno un'eccezione simile. [Groovy http builder] (http://groovy.codehaus.org/modules/http-builder/doc/ssl.html) [** SO1 **] (http://stackoverflow.com/questions/2642777/trusting- all-certificates-using-httpclient-over-https), [** SO2 **] (http://stackoverflow.com/questions/15837015/apache-http-client-javax-net-ssl-sslpeerunverifiedexception-peer-non -autentica), [** SO3 **] (http://stackoverflow.com/questions/9474313/java-javax-net-ssl-sslpeerunverifiedexception-peer-not-authenticated). –

risposta

3

Soluzione: La risposta che segue fornisce una soluzione per questo problema: https://stackoverflow.com/a/25076888/782034

appena scoperto che la nuova versione (0.7.1) del HttpBuilder introduce metodo:

ignoreSSLIssues() 

Questo risolve tutti i problemi relativi ai certificati SSL non validi (ovviamente lo devi essere consapevole che diminuisce anche la sicurezza).

Maggiori informazioni su questo metodo: http://groovy.codehaus.org/modules/http-builder/doc/ssl.html (sezione in basso)

cioè

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

Soluzione: Se si vuole fare le cose nel modo 'corretto' , controlla le altre soluzioni riguardanti l'importazione dei certificati del server. per esempio. SSLPeerUnverifiedException: peer not authenticated

+0

Sto usando 'ignoreSSLIssues()' e sto ancora ottenendo SSLPeerUnverifiedException. –

Problemi correlati