Diagnose and fix SSL problems in your PHP applications.
SSL errors with cURL are among the most frustrating for PHP developers. "SSL certificate problem: unable to get local issuer certificate" is the classic message.
These errors often occur after a server migration, PHP update, or when integrating third-party APIs.
This guide covers causes and solutions for the most common cURL SSL errors.
Typical cURL SSL error messages:
Why these errors occur:
How to resolve these errors:
Fixes for cURL SSL errors:
<?php
// Solution 1: Specify CA bundle in code
$ch = curl_init("https://api.example.com");
curl_setopt($ch, CURLOPT_CAINFO, "/path/to/cacert.pem");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
// Solution 2: Configure in php.ini
// curl.cainfo = "/path/to/cacert.pem"
// openssl.cafile = "/path/to/cacert.pem"
// BAD PRACTICE - DO NOT DO IN PRODUCTION
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Debug
curl_setopt($ch, CURLOPT_VERBOSE, true);
$verbose = fopen("php://temp", "w+");
curl_setopt($ch, CURLOPT_STDERR, $verbose);
Download cacert.pem: https://curl.se/docs/caextract.html
Avoid common pitfalls:
Only in development. NEVER in production, it exposes to MITM attacks.
curl.se/docs/caextract.html - it's the official Mozilla bundle.
Possibly. Test with SSL Labs if it's a third-party server.
PHP update, server change, or remote certificate expiration.
Yes, Guzzle uses cURL. Same solution: configure the CA bundle.
Create a cron that downloads cacert.pem periodically from curl.se.
cURL SSL errors are solved by correctly configuring the CA certificate bundle. Never disable verification.
Monitor your own certificates with MoniTao to avoid being the source of the problem for your clients.
Start free, no credit card required.