cURL error 60: SSL certificate: unable to get local issuer certificate

cURL error 60: SSL certificate: unable to get local issuer certificate

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

cURL error 60: SSL certificate: unable to get local issuer certificate

You are encountering cURL error 60 because your PHP environment cannot verify the SSL certificate presented by Stripe's servers. This specific error indicates that the CA (Certificate Authority) bundle used to validate the server's identity is missing, corrupted, or inaccessible to your PHP runtime. When you see the suggestion to download cacert.pem and modify php.ini, it addresses the root cause: PHP's cURL extension needs a trusted certificate store to perform peer verification.

The standard solution involves providing a path to a valid CA bundle. However, simply adding curl.cainfo = "C:\Windows\cacert.pem" to php.ini often fails in production environments. This usually happens because the web server (Apache or Nginx) and the CLI run under different user contexts with distinct file system permissions. If your Apache process cannot read the file you specified in php.ini, it will ignore the setting entirely, even after a restart.

A more robust approach is to pass this configuration directly within your application code using cURL options. Since you are using Laravel (indicated by Input::get and Redirect::route), you can bypass global configuration issues by instantiating the cURL handle explicitly or configuring the underlying stream context if using a library wrapper like Stripe's PHP SDK.

Configuring cURL via Code Options

In your controller, where you initialize the Stripe client, you can ensure peer verification happens by manipulating the cURL options before making the request. While the Stripe SDK abstracts the HTTP call, it relies on the underlying cURL library. If the global php.ini setting is ignored or missing, you must explicitly tell the library where to find the CA bundle.

Here is how you can modify your charge logic to handle SSL verification locally:

$stripe = new Stripe;
$stripe = \Stripe\Stripe::setApiKey(env('STRIPE_PUBLIC_KEY')); // Ensure key is set correctly

// Configure cURL options globally for this script or instance if needed
// Note: The Stripe SDK typically uses curl internally. 
// To force a specific CA bundle, you often need to use the underlying cURL handle
// or ensure your environment has the default cacert.pem accessible.

$charge = $stripe->charges()->create([
    'amount'   => 2900,
    'customer' => Input::get('stripeEmail'),
    'currency' => 'EUR',
]);

return Redirect::route('step1');

However, if you need to inject a specific cacert.pem file path into the cURL context (for example, if your system lacks the default bundle or is using a corporate proxy with custom certs), you must access the underlying cURL handle. The Stripe PHP library does not expose a direct method to set cURL options on every API call in older versions, but you can configure the global cURL defaults before initializing the client.

// Load the CA bundle if it exists locally
$caBundlePath = dirname(__FILE__) . '/cacert.pem';
if (file_exists($caBundlePath)) {
    curl_setopt_array(Stripe::$apiRequestor->getHttpClient(), [
        CURLOPT_CAINFO => $caBundlePath,
        CURLOPT_SSL_VERIFYPEER => true,
    ]);
}

Note: The above code assumes access to the Stripe SDK's internal cURL handle. If your version of the SDK does not expose this, you may need to upgrade or rely on environment configuration.

Verifying Environment Configuration

If modifying the code is not feasible due to library constraints, you must ensure your server configuration is correct. The error persists because curl.cainfo in php.ini was likely overwritten or ignored. Check which PHP binary your web server is actually using. Run php -i | grep "cainfo" from your terminal. If this returns nothing or a path to a non-existent file, the setting is not taking effect.

In many shared hosting environments, you cannot edit php.ini. In such cases, uploading cacert.pem to your public directory and modifying the application code to point to it is the only viable option without root access. Alternatively, using Composer to install a package that bundles the CA certificates (like guzzlehttp/guzzle) and configuring your requests through Guzzle might be cleaner than fighting with raw cURL options directly in Laravel's default HTTP client.

Why curl_setopt Doesn't Work on CLI

You mentioned that curl_setopt fails on the command line. This is a misconception about PHP functions versus system commands. The error you saw ("CLI doesn't find the command 'curl_setopt'") likely stems from mixing up the system curl executable with the PHP cURL extension functions. curl_setopt is a PHP function available only when running PHP code, not a standalone shell command. You cannot run curl_setopt directly in your terminal; you must invoke it inside a PHP script executed by CLI or via the web server.

Ensure that the SSL module is enabled in Apache and that the php_curl extension is loaded (extension=curl). Even with these modules enabled, if the CA bundle path is invalid or unreadable by the web server user (often www-data or apache), verification will fail. Always test your configuration by checking file permissions on the cacert.pem file to ensure the web server process has read access.

Our network