0

When i try to make payment using Paypal api it generate this error
'Curl error: SSL connect error'
- PHP version 5.4
but same code work in my local machine and i have PHP 5.6 in local machine
- is there version issue with this or somethings else ?

  • my curl code is
    
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_VERBOSE, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    curl_setopt($curl, CURLOPT_URL, $api_endpoint);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string);
    $result = curl_exec($curl);
    if(curl_exec($curl) === false)
    {
       echo 'Curl error: ' . curl_error($curl);
    }
    else
    {
      echo 'Curl Execuation Success...';
       } 
    curl_close($curl);
    
Ikhlak S.
  • 8,578
  • 10
  • 57
  • 77
Maher
  • 363
  • 2
  • 5
  • 18

1 Answers1

2

You should get the actual error code with

echo curl_errno($curl); // It might display a '59'

Find '59' at https://curl.haxx.se/libcurl/c/libcurl-errors.html which is CURLE_SSL_CIPHER (59) and read about the error and then research how to fix it.


Possible fix

Based on https://stackoverflow.com/a/4073567 you should try:

curl_setopt($curl, CURLOPT_SSLVERSION, 3);

This is potentially dangerous though, since it forces SSL3.

Community
  • 1
  • 1
MonkeyZeus
  • 20,375
  • 4
  • 36
  • 77
  • I commented with the same value but it could (should ?) be 6 (CURL_SSLVERSION_TLSv1_2, this is TLS v1.2 – Loenix Mar 15 '16 at 13:35
  • @Loenix I wonder if OP's PHP/cURL/openSSL version doesn't support the latest protocol. Maybe PayPal's API requirements are too high for PHP 5.4? – MonkeyZeus Mar 15 '16 at 13:38