PHP Curl SSL on Windows

When developing on Windows I regularly found myself using the line below to circument SSL errors on Windows when using Curl in PHP:

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

If I do not set these curl options, the request would fail with the message: Details: SSL3_GET_SERVER_CERTIFICATE:certificate verify failed. This is a
warning you normally only expect when connecting to a host with a self-signed certificate or something else. But on Windows this also happens for correct
certificates, because the certificate chain cannot be established. This can be solved in two steps:

  1. Download file with root certificates from http://curl.haxx.se/docs/caextract.html
  2. Add the lines below to your php.ini file (where the path is where you downloaded the file in step 1.

    [PHP_CURL]
    curl.cainfo=c:\apps\php\cacert.pem

This post is based on a solution in a stackoverflow post.