Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paypal Access - SSL certificate: unable to get local issuer certificate

Tags:

php

curl

ssl

paypal

I'm working with cUrl and PHP to make a request to a server (for paypal access)

Paypal developer website does never mention that an SSL certificate is required to use PayPal access API, however the code that I use to request the token is the following:

$options = array(                 CURLOPT_URL => $url,                 CURLOPT_POST => 1,                 CURLOPT_VERBOSE => 1,                 CURLOPT_POSTFIELDS => $postvals,                 CURLOPT_RETURNTRANSFER => 1,                 CURLOPT_SSLVERSION => 3 );  curl_setopt_array($ch, $options);  $response = curl_exec($ch);  echo curl_error($ch); 

This echo outputs the following error:

SSL certificate problem: unable to get local issuer certificate 

My questions are:

1) do I need SSL to use paypal access if I need only to get the user email?

2) if I do not need SSL why this error occours?

PS: the endpoint is the following: https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/tokenservice

like image 678
Luca Pennisi Avatar asked Jul 04 '13 21:07

Luca Pennisi


People also ask

How do I fix unable to get local issuer certificate?

When ssl certificate problem unable to get local issuer certificate error is caused by a self-signed certificate, the fix is to add the certificate to the trusted certificate store. Open the file ca-bundle. crt located in the directory above, then copy and paste the Git SSL certificate to the end of the file.

Do I need SSL if I use PayPal?

Do you use PayPal on your online store? If you have an ecommerce website that's using PayPal, you will shortly need to have an SSL Certificate (https) installed otherwise paypal payments will not be received. The majority of ecommerce platforms (Magento, Woocommerce, Opencart all use PayPal's IPN).

How do I find the issuer of a certificate?

The steps to view the certificate information depend on the browser. For instance, in Google Chrome, click on the lock icon in the address bar, switch to the the Connection tab and click on Certificate Information . Search for the issuer organization name.


2 Answers

The correct solution is to fix your PHP setup.. setting CURLOPT_SSL_VERIFYPEER to false is a quick hack, but it's wrong as you disable the certificate validation by it's certificate authority. This exposes you to a man-in-the-middle attack.

It's easy to fix (php 5.3.7 or higher) - Download a list file with an up-to-date certificate authorities, and add this setting to your php.ini
curl.cainfo=<path-to>cacert.pem

Restart your web server, and it'll work !

like image 161
oori Avatar answered Sep 24 '22 20:09

oori


You may disable SSL verification (which is enabled by default as of cURL 7.10), by adding this:

CURLOPT_SSL_VERIFYPEER, false 

to your $options, however the proper way is to keep validation enabled.

SECURITY NOTICE

If remote site uses certificate issued by known CA but validation still fails, then most likely certificate is incorrectly set up on the remote server (lack of intermediate certificates etc.). Alternatively your system got no idea about used Certificate Authority that signed target's certificate. In such case yo should use php.ini's curl.cainfo (documentation) to point to valid PEM file with all supported CAs - that would make your setup properly validate issuer chain.

Please be aware that by setting CURLOPT_SSL_VERIFYPEER to false you are NOT solving the issue! You are working it around. This is all about security so it's fine to do that for a while, but deploying that on production is not wise, politely speaking, as you will become open to Man In The Middle Attack. You have been warned.

like image 20
Marcin Orlowski Avatar answered Sep 26 '22 20:09

Marcin Orlowski