PHP cURL or Guzzle fails with SSL certificate error 60
cURL error 60: SSL certificate problem: unable to get local issuer certificateShort answer
cURL cannot find a trusted CA file to check the server's certificate against. Download a current CA bundle, set curl.cainfo to its absolute path in the php.ini that your PHP really loads, then restart PHP. Do not set verify to false; that removes the protection.
Fix it fast
1Find out which cause you have
Find out which php.ini PHP loaded and whether curl.cainfo is already set. Edit that file, not another copy.
php --ini php -r "var_dump(ini_get('curl.cainfo'), ini_get('openssl.cafile'));"2Match what you see, then jump to its fix
- 1
curl.cainfo is empty and the error appears for every https site.No CA bundle is configured for PHPFix - 2
curl.cainfo is set in a file but ini_get still returns an empty value.You edited a php.ini that PHP does not loadFix - 3
Only one API or a corporate proxy host fails; others work.One request needs its own CA fileFix
- 1
What does the error look like?
cURL error 60: SSL certificate problem: unable to get local issuer certificatecurl: (60) SSL certificate problem: unable to get local issuer certificate
Cause 1 of 3
No CA bundle is configured for PHP
1Check
curl verifies certificates by default and needs a store of trusted CAs. PHP's curl.cainfo ini setting provides the default file and must be an absolute path. On many Windows installs nothing is set.
php -r "var_dump(ini_get('curl.cainfo'));"
curl -s -o /dev/null -w "%{http_code}\n" https://example.com2Fix
Download the PEM bundle that curl publishes, store it outside the web root, and set the path in php.ini.
; php.ini
curl.cainfo = "/etc/ssl/certs/cacert.pem"
; Windows example:
; curl.cainfo = "C:\php\extras\ssl\cacert.pem"3Verify
Restart PHP-FPM or the web server, and the value shows up.
sudo systemctl restart php8.3-fpm
php -r "var_dump(ini_get('curl.cainfo'));"Confirmed by php.net
Cause 2 of 3
You edited a php.ini that PHP does not load
1Check
CLI and web server PHP can read different files. The loaded file is listed by php --ini, and by phpinfo() for the web server.
php --ini
php -r "var_dump(php_ini_loaded_file());"2Fix
Put the setting in the file each SAPI loads, or in a .ini file inside the directory that php --ini lists as the scan directory for additional .ini files.
# in each php.ini that is loaded (CLI and web server):
curl.cainfo = "/etc/ssl/certs/cacert.pem"3Verify
Compare both SAPIs after saving the file and restarting.
php -r "echo ini_get('curl.cainfo');"Confirmed by php.net
Cause 3 of 3
One request needs its own CA file
1Check
A private CA or an intercepting proxy is not in the public bundle, so that one host fails verification. curl can verify against a single file you give it for that transfer.
curl --cacert /path/to/corp-ca.pem -I https://api.internal.example2Fix
Pass the file for that client only, for example in Guzzle.
$client = new GuzzleHttp\Client(['verify' => '/path/to/corp-ca.pem']);3Verify
The request now succeeds and other hosts are unaffected.
php -r "echo (new GuzzleHttp\Client(['verify'=>'/path/to/corp-ca.pem']))->get('https://api.internal.example')->getStatusCode();"Confirmed by curl.se
How do I stop it coming back?
- Refresh the CA bundle on a schedule; an old bundle misses newer roots.
- Never ship verify=false or CURLOPT_SSL_VERIFYPEER=0; curl's docs call disabling verification strongly discouraged.
- Keep one shared ini file for CLI and FPM so they cannot drift.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
Apache returns 403 when a URL contains %3F
a request like /page%3Fname=test is refused while /page?name=test works
Recent Apache httpd blocks a rewrite when the request contains an encoded question mark (%3F) and the rewritten target has a literal ?.
2 causes, each with a fixBack end
Apache returns 500 with Premature end of script headers
500 Internal Server Error
Apache ran your script, but the script printed no valid HTTP header before its output.
3 causes, each with a fixBack end
Apache returns 503 or 504 because PHP-FPM did not answer in time
Error dispatching request
Apache sent the request to PHP-FPM and gave up waiting.
3 causes, each with a fixBack end
AWS SDK for PHP cannot get credentials from the instance profile metadata server
Error retrieving credentials from the instance profile metadata server.
The SDK tries the EC2 instance metadata service when it has no valid credentials from anywhere earlier in its chain.
4 causes, each with a fixBack end
AWS SDK for PHP rejects requests: the signature is from the future
Signature not yet current: {date} is still later than {date}
AWS compares the timestamp in your signed request with its own clock.
2 causes, each with a fix