cURL certificate verification on Windows Servers

I recently lost about five hours time on this issue, so here is my fix:

If you get this error message when trying to validate cURL certificates on Windows machines:

Curl returned error 60: SSL certificate problem, verify that the CA cert is OK. Details:error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

  1. Be advised that curl_setopt($handle, CURLOPT_CAPATH,...) command is NOT working on Windows machines, due to some issues with openssl.
  2. You must instead work with the CURLOPT_CAINFO flag in above command.
  3. Get Mozilla’s certificate authority bundle file from here: https://curl.haxx.se/docs/caextract.html
  4. Point curl to it with above flag (2).

Working code should look like this:

curl_setopt($handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, TRUE);

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn