0

I'm experiencing a problem accessing a paypal (sandbox) API. The code

import groovyx.net.http.*
import static groovyx.net.http.ContentType.*
import static groovyx.net.http.Method.*

HTTPBuilder http = new HTTPBuilder( 'https://api.sandbox.paypal.com/v1' )
http.auth.basic clientId, secret
http.headers.Accept = 'application/json'
http.headers[ 'Accept-Language' ] = 'en_US'
http.request( POST ){
  uri.path = '/oauth2/token'
  requestContentType = URLENC
  body = 'grant_type=client_credentials'

  response.success = { resp, json ->
    println json
  } 
}

on my local computer gives

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

If i run a curl

curl -v https://api.sandbox.paypal.com/v1/oauth2/token -H "Accept: application/json" -H "Accept-Language: en_US" -H "Authorization: Basic {base64 text}=" -d "grant_type=client_credentials"

I get:

curl: (35) error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

If I run the same query in Postman, it runs smoothly.

What am I missing?

UPDATE:

If I add -Djavax.net.debug=ssl:handshake, the following debug info appears

http-bio-8880-exec-3, WRITE: TLSv1 Handshake, length = 149 http-bio-8880-exec-3, READ: TLSv1 Alert, length = 2 http-bio-8880-exec-3 , RECV TLSv1 ALERT:
fatal, handshake_failure http-bio-8880-exec-3, called closeSocket() http-bio-8880-exec-3, handling exception: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

injecteer
  • 20,038
  • 4
  • 45
  • 89

0 Answers0