PHP how to make work curl with CURLOPT_SSL_VERIFYHOST or fix php curl SSL certificate

Updated: 23th March 2022
Tags: php curl

If you want your curl request to work, you have two options

Method 1: Disable SSL_VERIFY (meh)

Add options to your curl request.

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

Also disabling verify host will work for ya. But you can't be sure all curl requests have this options. So I strongly recommend to fix the root of the cause.

Method 2: Add certificate to your php.ini (good)

Download certificate from here and save it to C:\php\cacert.pem

Change values in php.ini


Make sure this line is uncommented


In older versions it can be this