Greg
Greg

Reputation: 2493

PHP CURL CURLOPT_SSL_VERIFYPEER ignored

For some reason I am unable to use CURL with HTTPS. Everything was working fine untill I ran upgrade of curl libraries. Now I am experiencing this response when trying to perform CURL requests: Problem with the SSL CA cert (path? access rights?)

Following suggestions posted here on related issues I have tried to do the following:

Unfortunatelly none of the above are able to solve my problem and I constantly get Problem with the SSL CA cert (path? access rights?) message.

And I don't need this verification in the first place (I am aware of security issues).

Does anybody have any other suggestions?

UPDATE

After updating to the latest libraries and restart of the whole box, not just apache which I was doing it all seems to be working now again!!!

Upvotes: 164

Views: 462093

Answers (5)

rahul saini
rahul saini

Reputation: 1

curl_setopt($this->fp, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($this->fp, CURLOPT_SSL_VERIFYPEER, false);

use these line in razorpay-php/libs/Requests-1.6.1/library/Requests/Transport/cURL.php

Upvotes: 0

ankit upadhyay
ankit upadhyay

Reputation: 11

Try below if working for you:

For SSL verification we need to set 2

CURLOPT_SSL_VERIFYHOST = 2
CURLOPT_SSL_VERIFYPEER = 2

For not verification we need to set 0

CURLOPT_SSL_VERIFYHOST = 0
CURLOPT_SSL_VERIFYPEER = 0

default is always false

Upvotes: 1

$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Return data inplace of echoing on screen
curl_setopt($ch, CURLOPT_URL, $strURL);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Skip SSL Verification
$rsData = curl_exec($ch);
curl_close($ch);
return $rsData;

Upvotes: 7

clover
clover

Reputation: 5170

According to documentation: to verify host or peer certificate you need to specify alternate certificates with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option.

Also look at CURLOPT_SSL_VERIFYHOST:

  • 1 to check the existence of a common name in the SSL peer certificate.
  • 2 to check the existence of a common name and also verify that it matches the hostname provided.

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

Upvotes: 336

Rvanlaak
Rvanlaak

Reputation: 3085

We had the same problem on a CentOS7 machine. Disabling the VERIFYHOST VERIFYPEER did not solve the problem, we did not have the cURL error anymore but the response still was invalid. Doing a wget to the same link as the cURL was doing also resulted in a certificate error.

-> Our solution also was to reboot the VPS, this solved it and we were able to complete the request again.

For us this seemed to be a memory corruption problem. Rebooting the VPS reloaded the libary in the memory again and now it works. So if the above solution from @clover does not work try to reboot your machine.

Upvotes: 3

Related Questions