Menu Close

PHP Fatal error: Uncaught cURL error 60: SSL certificate problem: unable to get local issuer certificate

The error message you’re encountering, “cURL error 60: SSL certificate problem: unable to get local issuer certificate,” typically occurs when PHP’s cURL extension cannot verify the SSL certificate of the remote server. This error is often seen when you’re trying to make an HTTPS request using cURL, and the CA (Certificate Authority) certificates are not correctly set up on your server.

General Fix

To resolve this issue, you can do the following:

  1. Update CA Certificates: Update the CA certificates bundle on your server. You can typically do this by installing the latest CA certificates bundle package for your operating system. For example, on Debian/Ubuntu, you can run:
    sudo apt-get install --reinstall ca-certificates
  2. Specify a Certificate Authority File: You can specify a certificate authority file explicitly in your cURL request. You can use the CURLOPT_CAINFO option to set the path to the CA bundle file. Here’s an example in PHP:
    $url = "https://example.com";
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem"); // Path to the CA certificate bundle
    $response = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'cURL error: ' . curl_error($ch);
    }
    curl_close($ch);

    Replace "/path/to/cacert.pem" with the actual path to the CA certificate bundle file on your server.

WAMP

If you run your php on WAMP Server, you can follow this step:

  1. You can download the cacert.pem file directly from the cURL website. They provide a regularly updated version of the CA certificate bundle. You can download it from the following link: cURL CA Extract
  2. Copy the cacert.pem file to the PHP directory. In my case is C:\wamp\bin\php\php8.1.13
  3. Open the PHP configuration file called php.ini, on WAMP beside on your PHP folder, it’s also on C:\wamp\bin\apache\yourApacheVersion. Find and uncomment “curl.cainfo”, add the following lines:
    curl.cainfo = "C:\wamp\bin\php\php8.1.13\cacert.pem"

    see point 2, where you copy cacert.pem file

  4. Still on php.ini file, uncomment extension=openssl
  5. Edit httpd.conf file on C:\wamp\bin\apache\yourApacehVersion\conf, find and uncomment this line
    LoadModule ssl_module modules/mod_ssl.so

Done, you need to restart your WAMP

Leave a Reply

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