Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paypal ssl handshake faliure

Hi I am using Paypal PHP SDK to communicate with Paypal Api.

2 days before every thing was working fine. But now I am getting this error on my development servers.

error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

I am using the following CURL options while requesting:

public static $DEFAULT_CURL_OPTS = array(
    CURLOPT_SSLVERSION => 1,
    CURLOPT_CONNECTTIMEOUT => 10,
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_TIMEOUT        => 60,   // maximum number of seconds to allow cURL functions to execute
    CURLOPT_USERAGENT      => 'PayPal-PHP-SDK',
    CURLOPT_HTTPHEADER     => array(),
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_SSL_VERIFYPEER => 1,
    CURLOPT_SSL_CIPHER_LIST => 'TLSv1',
);

This problem only occuring using SANDBOX mode on live mode every thing works fine.

Any body knows why this is happening?

Thank You

like image 534
Muhammad Umair Avatar asked Jan 22 '16 14:01

Muhammad Umair


1 Answers

I've experienced the same error. It's due to recent updates that PayPal have made: https://www.paypal-knowledge.com/infocenter/index?page=content&id=FAQ1766

You can fix it by adding this to your CURL options:

curl_setopt($ch, CURLOPT_SSLVERSION , 1);

or

CURLOPT_SSL_SSLVERSION => 1

EDIT: Complete working settings

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
curl_setopt($ch, CURLOPT_SSLVERSION , 1);
like image 97
Jaz Parkyn Avatar answered Dec 19 '22 17:12

Jaz Parkyn