xampp + php + curl + ssl = fatal_error

If you use xampp with php and curl you might encounter an error like this:

Fatal error: Uncaught exception 'HttpClientException' with message 'cURL Error: SSL certificate problem: unable to get local issuer certificate' in HttpClient.php

If this is the case the solution is easy:

  1. Download cacert.pem from official curl page https://curl.haxx.se/docs/caextract.html
  2. Copy cacert.pem to c:\xampp\cacert.pem (assuming your xampp installation resides on c:\xampp)
  3. Make sure mod_ssl in enabled on apache (assuming your apache configurations are lying on C:\xampp\apache\conf). Open httpd.conf and make sure line LoadModule ssl_module modules/mod_ssl.so is not commented. Comments are prefixed with #. Disable comment simply by removing #.
  4. Now open php.ini (assuming php.ini is C:\xampp\php). Proportionally to the apache config, locate line extension=php_openssl.dll, remove comment (by deleting #). Make sure you have php_openssl.dll in C:\xampp\php\ext although there’s no reason not have it, I guess if this is the case, you should check the whole xampp installation.
  5. Stay a little bit on php.ini and add the following entries:

    Make sure the paths are correct according to what you have determined in step 1.

  6. This is not required, but if you like keep things tidy in php.ini, move curl.cainfo and openssl.cafile to the proper sections of the php.ini  [curl] and [openssl] respectively.
  7. Restart apache, otherwise your changes won’t have any effect. Reload your page and the error should have been removed.

I hope you’ve found this useful.




Leave a Reply

Your email address will not be published. Required fields are marked *