How to Migrate cPanel Accounts Between Servers Using WHM Transfer Tool (Zero-Downtime Guide) Moving live…
Curl Unable to Get Local Issuer Certificate: Fix

When you run a curl command to access an HTTPS website or API, you may encounter the following error:
curl: (60) SSL certificate problem: unable to get local issuer certificate
This error means curl cannot establish a trusted certificate chain for the remote server. The cause may be an outdated or missing Certificate Authority (CA) bundle, an incomplete certificate chain on the server, an untrusted private CA, or an HTTPS-inspecting proxy.
The error commonly affects Linux VPS environments, API integrations, automated deployment scripts, PHP applications, and containerized workloads.
In this guide, you will learn how to troubleshoot the error, repair CA certificates, inspect certificate chains, check system time, and restore secure HTTPS connections without disabling TLS verification.
What Does “Unable to Get Local Issuer Certificate” Mean?
HTTPS uses Transport Layer Security (TLS) to protect communication between a client and a server. During a TLS handshake, curl verifies the server’s certificate against its trusted Certificate Authority certificates.
A typical certificate chain contains:
- Server certificate: Identifies the hostname being accessed.
- Intermediate CA certificate: Connects the server certificate to a trusted root.
- Root CA certificate: Establishes the trust anchor used to validate the chain.
If curl cannot build a valid chain to a trusted certificate authority, it rejects the connection.
For example, a server might present its own certificate but fail to send a required intermediate certificate. Alternatively, the server may present a complete chain while the client uses an outdated CA bundle.
Curl reports the verification failure instead of silently trusting an unverified connection. This is an important security feature, not something that should be bypassed in production.
Reference: https://curl.se/docs/sslcerts.html
Common Causes of Curl SSL Certificate Errors
Before changing your server configuration, identify the likely cause.
1. Missing or outdated CA certificates
Minimal Linux installations and container images may not include the ca-certificates package. Older systems may also have outdated trust stores.
2. Incomplete server certificate chain
The remote server may be configured with its leaf certificate instead of the complete certificate chain. This can cause curl to fail even when a browser appears to work.
3. Incorrect system date and time
An incorrect system clock can cause certificate validity checks to fail. This more commonly produces an expired or not-yet-valid certificate error, but it should still be checked during TLS troubleshooting.
4. Private or self-signed certificate
An internal API, development server, or private service may use a certificate issued by an internal CA that curl does not trust by default.
5. HTTPS-inspecting proxy
A corporate firewall, proxy, or security appliance may issue replacement certificates signed by its own CA. If that CA is not trusted by curl, certificate verification fails.
6. Curl uses a different CA bundle
Your curl binary may use a custom CA file or a different TLS backend than other applications on the same machine. As a result, a browser or another command-line tool may work while curl fails.
Step 1: Confirm the Error and Inspect Curl’s Configuration
Start by checking the curl version and TLS backend:
curl -V
This displays the curl version, supported protocols, and TLS-related build information.
Next, run a verbose request against the affected hostname:
curl -v https://api.example.com -o /dev/null
Replace api.example.com with the actual hostname.
Look for certificate-related output, including the CA file and CA directory curl attempts to use. Depending on the build, the output may include lines similar to:
CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
The paths will vary by operating system and curl build.
Do not share verbose output publicly without reviewing it first, as it may contain hostnames, proxy details, or other operational information.
If every HTTPS destination fails, investigate the local CA store first. If only one destination fails, investigate that server’s certificate chain and hostname configuration.
Step 2: Install or Update the CA Certificate Bundle
If the CA bundle is missing or outdated, use your operating system’s package manager to install or update it.
Debian and Ubuntu
Update the package index and install the CA certificates package:
sudo apt update
sudo apt install --reinstall ca-certificates
sudo update-ca-certificates
The system CA bundle is commonly located at:
/etc/ssl/certs/ca-certificates.crt
Check whether the file exists:
ls -l /etc/ssl/certs/ca-certificates.crt
RHEL, Rocky Linux, AlmaLinux, and Fedora
On systems using DNF, install or update the CA certificates package:
sudo dnf install ca-certificates
sudo dnf reinstall ca-certificates
sudo update-ca-trust
The traditional system trust store commonly includes:
/etc/pki/tls/certs/ca-bundle.crt
The precise bundle path depends on the operating system and how curl was built.
Verify the repair
After updating the CA store, retry the original request:
curl -v https://api.example.com
If the request succeeds, confirm that it is using the expected certificate chain and trust store.
If the error persists, do not repeatedly reinstall packages without further investigation. The server may be sending an incomplete chain, or curl may be using a different CA file.
Step 3: Check the Certificate Chain Presented by the Server
When a single hostname fails, inspect the certificates presented during the TLS handshake.
Run:
openssl s_client \
-connect api.example.com:443 \
-servername api.example.com \
-showcerts \
-verify_return_error </dev/null
Replace api.example.com with the actual hostname.
The -servername option sends the hostname using Server Name Indication (SNI), helping the server present the correct certificate for that domain.
Review the certificate details and verification result. Look for missing intermediate certificates, untrusted issuers, expired certificates, and hostname-related issues.
You can also display the certificate subjects and issuers:
openssl s_client \
-connect api.example.com:443 \
-servername api.example.com \
-showcerts </dev/null 2>/dev/null |
grep -E 'subject=|issuer='
This provides a quick view of the chain information, but it is not a complete certificate validation procedure by itself.
What if the server is missing an intermediate certificate?
If you administer the affected website or API, inspect its TLS configuration.
For Nginx, the certificate file commonly needs to contain the server certificate followed by the required intermediate certificates. A typical configuration uses:
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
Use the actual certificate paths for your installation. The example assumes a certificate managed by Let’s Encrypt.
After checking the configuration, test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
For Apache, configure the certificate and chain according to the installed Apache version and its TLS module. Modern configurations commonly use a full-chain certificate file with SSLCertificateFile.
If you do not administer the remote server, contact its administrator or hosting provider and ask them to verify that the server presents the complete certificate chain.
Fixing an incomplete chain at the server is generally preferable to changing every client that connects to it.
Step 4: Check the System Date and Time
Certificate validation depends on the system’s clock being reasonably accurate.
Check the current time:
date
timedatectl status
Review the displayed date, timezone, and time synchronization status.
If the clock is significantly incorrect, investigate the configured time synchronization service.
On a system using systemd, you can inspect available time synchronization services and settings:
timedatectl show
If your system uses Chrony, check its synchronization status:
chronyc tracking
chronyc sources
These commands require Chrony to be installed and configured.
Correct the time through your operating system’s supported time synchronization configuration. Do not manually change production server time without considering the impact on running applications, logs, scheduled tasks, and distributed systems.
Once the clock is correct, retry the original curl request.
Step 5: Check Whether Curl Uses a Custom CA Bundle
Curl can use a custom CA certificate file instead of the default trust store.
Check whether any CA-related environment variables are set:
env | grep -E '^(CURL_CA_BUNDLE|SSL_CERT_FILE|SSL_CERT_DIR)='
These variables can influence certificate lookup, depending on the curl build and TLS backend.
For example, an outdated CURL_CA_BUNDLE value may point to a missing file or an incomplete bundle.
If the application requires a specific CA bundle, confirm that the file exists and contains the appropriate trusted certificates.
You can test a verified CA bundle explicitly:
curl --cacert /path/to/verified-ca-bundle.pem \
https://api.example.com
Replace the example path with a trusted, valid CA bundle.
Be aware that --cacert specifies the CA file used for that request; it should not be treated as an automatic addition to every existing trust source. Make sure the specified file contains the certificates needed to validate the destination.
Do not download arbitrary certificate files from untrusted sources. Obtain public CA updates through your operating system’s package manager or obtain private CA certificates from the organization that operates the service.
Step 6: Troubleshoot Private CAs and Internal APIs
Private services often use certificates issued by an internal Certificate Authority.
Examples include:
- Internal company APIs.
- Development and staging environments.
- Private management interfaces.
- Services behind a TLS-inspecting proxy.
If the certificate is legitimately issued by an internal CA, obtain the trusted CA certificate from the responsible administrator and verify its authenticity through an independent, trusted channel.
Install a private CA on Debian or Ubuntu
For a verified PEM-format CA certificate, a typical system-wide installation procedure is:
sudo install -m 0644 internal-root-ca.crt \
/usr/local/share/ca-certificates/internal-root-ca.crt
sudo update-ca-certificates
Replace internal-root-ca.crt with the actual verified certificate file.
The file must use the expected certificate format and naming conventions for the distribution’s trust-store utility.
This changes the system-wide trust store for applications that use it. Review organizational security requirements before trusting an internal CA.
After installation, test the connection again:
curl https://internal-api.example.com
If curl uses its own custom CA bundle or a different TLS backend, additional configuration may be necessary.
Step 7: Check Containers and Application Environments
A request may work on the VPS host but fail inside a container or application runtime.
Minimal container images sometimes omit the CA certificates package. The container may also use a different trust store from the host.
For a Debian-based container, check whether the package is installed:
dpkg -l ca-certificates
For an Alpine-based container:
apk info ca-certificates
If the package is missing, install it through the image’s package manager and rebuild the image. For production workloads, make this part of the Dockerfile or image build process rather than relying on a manual fix inside a running container.
Also check whether the failing request originates from PHP, Python, Git, or another application. Those tools may use different certificate stores or runtime-specific configuration.
If the command-line curl works but the application fails, investigate the application’s TLS configuration separately.
Step 8: Verify the Final Result
After applying the appropriate fix, test the connection without disabling verification:
curl -sS -o /dev/null \
-w 'HTTP status: %{http_code}\n' \
https://api.example.com
A successful TLS handshake may return an HTTP status such as 200, 301, 401, or 403, depending on the endpoint and authentication requirements. The important point is that certificate verification completes successfully.
If the command still fails, return to the verbose output and identify whether the failure is caused by the local trust store, the server certificate chain, the system clock, or an intermediary proxy.
Avoid making unrelated TLS configuration changes when the underlying cause has not been established.
Common Mistakes to Avoid
Do not use curl -k as a production fix
The -k or --insecure option disables certificate verification. It can allow curl to connect without establishing that the remote endpoint is trusted.
This weakens protection against man-in-the-middle attacks and should not be used as a permanent solution.
Do not replace the entire CA store with a single certificate
A single internal CA certificate may not be sufficient to validate unrelated public websites. Preserve the operating system’s normal trust store and install additional trusted CAs through the supported mechanism.
Do not assume every error comes from the client
If the remote server omits an intermediate certificate, updating the client’s CA bundle may not solve the actual problem. Inspect the chain before changing system configuration.
Do not ignore certificate hostname errors
A trusted certificate must also be valid for the hostname being accessed. Fix hostname or certificate configuration problems rather than bypassing verification.
The curl unable to get local issuer certificate error usually points to a problem building a trusted certificate chain. The most effective troubleshooting process is to inspect curl’s CA configuration, update the operating system’s CA bundle when necessary, verify the server’s certificate chain, and check system time and private CA requirements.
If the remote server is missing an intermediate certificate, correct the server configuration. If the client is missing a legitimate trusted CA, update its trust store through the appropriate system or application mechanism.
By fixing the underlying cause instead of disabling TLS verification, you can restore secure HTTPS connections and keep your Linux VPS applications protected.
Keep Your VPS Workloads Reliable
Reliable hosting depends on correctly configured TLS, current security certificates, and a well-maintained server environment.
Explore ServerNext for hosting solutions, or review the available BDIX VPS plans if you need a VPS for websites, APIs, or development workloads.
Choose a configuration that matches your application’s requirements, and keep your operating system, CA certificates, and TLS configuration maintained as part of your regular server administration routine.
