0

I'm trying to make a request to Cloudflare Websites. Until yesterday I had a working script but now it seems like the requests are sent back empty. Now the problem seems to be very weird because of the following reasons: *It was working fine until yesterday. *It happens only on websites require an SSL connection. *The same code works on my localhost, but not on my server.

Here's the code that I'm using:

$ch = curl_init();
$curlConfig = array(
CURLOPT_URL            => $url,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6',
CURLOPT_FOLLOWLOCATION => 1
);
curl_setopt_array($ch, $curlConfig);
$result = curl_exec($ch);
curl_close($ch);

As you can see the code is very simple but I just can't figure out why it would not work on my server while on my localhost (XAMPP) it works great.

Thanks ahead and have a great day!

user2298995
  • 2,045
  • 3
  • 19
  • 27

1 Answers1

1

Does your local curl set-up support using ECC SSL certificates?

If this is only happening on sites with a free CloudFlare account (as opposed to a pro one), it means your curl installation cannot connect to sites which are using Elliptic Curve Cryptography ciphers for SSLs.

You need to have these ciphers installed on your server. You mentioned it doesn't work on servers whilst it works fine on XAMPP. This is likely as your local machine has these ciphers installed while your computer does not. You can do this on Linux environments by upgrading your version of OpenSSL.

That should sort your problem. Have fun, be sure not to get blocked from CloudFlare by their firewall!

mjsa
  • 4,221
  • 1
  • 25
  • 35
  • I downloaded certificate `DER encoded binary x.509(.cer)` from chrome and convert it to `.pem` file, set it on `CURL` but didn't resolved my problem, see details: https://stackoverflow.com/q/71529199/1407491 – Nabi K.A.Z. Mar 18 '22 at 17:46