3
In the code where an API call is executed, there is the following line:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
When executing the code the following error is returned:
SSL Certificate problem: Unable to get local Issuer Certificate - Code: 60
Soon after, the following code was added:
if (curl_errno($ch) == 60) {
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '\cacert.pem');
$result = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
}
What makes the file "cacert.pem" and why when setting "CURLOPT_SSL_VERIFYPEER" to "true" the error is returned?
I do not know if it is the same thing or not, but by the name of the file it seems to me that it should contain the root certificate of the certifying authority (CA) that issued the security certificate of your site. Reusing from one project to another can make it invalid, as pointed out in Vinicius' response. If you purchased your security certificate on site X, look on that same site for more information, they probably provide the right file and instructions on how to use it properly (mine, Startssl, even sent me an automated e-mail with these instructions the first time I made a mistake).
– mgibsonbr
@mgibsonbr The file has data such as "Verisign Class 3 Public Primary Certification Authority". This file is used in the Paypal SDK/PHP, however I reused it to create a second SDK/PHP for an online billing system that also uses REST+Oauth (but does not have a ready-made SDK/PHP). The project is the same, the features are different. For Paypal it worked, for the billing system no.
– Filipe Moraes