This error shows up in code that talks to an outside service: a payment gateway, a shipping API, WordPress updates or Composer packages. It’s raised on the requesting side, in your code, but in many cases the cause sits on the server you’re connecting to.
What the error means
Before sending anything over HTTPS, cURL checks that the other side’s SSL certificate was issued by a trusted authority and that the chain is complete: the site’s certificate, then the intermediate, then a root found in your CA bundle. If the chain breaks or no CA bundle is found, it refuses the connection with code 60. Common variants:
unable to get local issuer certificate: it couldn’t build a chain up to a trusted authority.certificate has expired: the certificate expired, or the machine’s clock is wrong.self-signed certificate in certificate chain: a self-signed certificate, or security software intercepting traffic.no alternative certificate subject name matches target host name: the certificate was issued for a different domain.
Common causes
- The remote server doesn’t send its intermediate certificate. This is the most common cause.
- PHP on a development machine, especially XAMPP or WAMP on Windows, with no CA bundle configured.
- An expired certificate on the remote server, or a self-signed one on an internal API.
- Antivirus software or a proxy inspecting HTTPS on your computer.
- Your site calling itself, such as WordPress’s loopback check, before its certificate has been issued; see AutoSSL failed.
How to fix it
- Find out which side is at fault: test the domain your code calls, from your computer or over SSH:
curl -v https://api.example.com/
openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts </dev/null
In the openssl output, look for Verify return code. 0 (ok) means the chain is fine; 21 (unable to verify the first certificate) usually means that server is missing its intermediate.
2. If you own the remote server: install the certificate with its full chain. In cPanel, AutoSSL installs the chain automatically.
3. If it’s a third party: tell them their intermediate certificate is missing. Until they fix it, you can add their chain to a project-specific CA file.
4. On a development machine: download the cacert.pem file published by the curl project and add this to php.ini:
curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem"
openssl.cafile = "C:\xampp\php\extras\ssl\cacert.pem"
Then restart Apache. 5. For an API signed by an internal CA: point cURL at that CA instead of disabling verification:
$ch = curl_init('https://internal-api.example.com/status');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . '/certs/internal-ca.pem');
$response = curl_exec($ch);
In Laravel:
Http::withOptions(['verify' => storage_path('certs/internal-ca.pem')])->get($url);
- Check the clock: a wrong time makes valid certificates look expired. Check it with
date.
Prevention
- Never ship code with
CURLOPT_SSL_VERIFYPEERor'verify' => false. - Track your certificates’ expiry dates, and use auto-renewing certificates such as Let’s Encrypt.
- When connecting a new service, test the connection from the server itself, not only from a browser.
On ArabyHost
A free SSL certificate is issued automatically for your domains through AutoSSL and Let’s Encrypt. If the remote end is a site on your account and the error appeared right after connecting the domain, wait for issuance to finish or check the AutoSSL status. On AI/Developer plans you have SSH to run curl -v and openssl s_client from the server itself. The Araby AI assistant reads the error log and names the domain the connection failed for.
FAQ
The site opens fine in my browser, so why does cURL fail?
Some browsers fill in a missing intermediate certificate automatically or remember it from earlier visits; cURL doesn't. So a site can load in a browser while its certificate chain is genuinely incomplete.
Should I disable CURLOPT_SSL_VERIFYPEER?
Not on a live site. Turning verification off exposes the connection to man-in-the-middle attacks, so API keys or payment data could be stolen. Use it only for a temporary local test, then fix the cause.
Why does it only happen in XAMPP or WAMP on Windows?
PHP on Windows has no CA bundle by default. Download the cacert.pem file published by the curl project, set its path in curl.cainfo and openssl.cafile in php.ini, and restart Apache.