Fix unable to get local issuer certificate (Incomplete SSL/TLS Chain)

What the OpenSSL error unable to get local issuer certificate means, how to tell a server missing its intermediate certificate from a client missing a root, and how to fix the chain in nginx, Apache, curl and mail servers.

Home › Guides › Unable to get local issuer certificate

Last updated 17 November 2026

Quick answer

OpenSSL's documentation defines the error X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY (text: unable to get local issuer certificate) as: The issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found. In practice the client couldn't build a chain from the server's certificate to a root it trusts. It usually comes down to one of two things:

  1. The server doesn't send its intermediate CA certificate(s). Fix the server so it sends the leaf certificate followed by the intermediates.
  2. The client doesn't trust the root. Common with a private or internal CA. Add the CA to the client's trust store or point the client at the right CA bundle.

Don't turn off verification to make it go away. curl's documentation strongly recommends never skipping verification (-k / --insecure) in production.

Related OpenSSL verification errors

OpenSSL-based clients report these texts, from X509_STORE_CTX_get_error(3):

Error textOpenSSL's description
unable to get local issuer certificateThe issuer certificate of an untrusted certificate cannot be found.
unable to get issuer certificateThe issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete.
unable to verify the first certificateThe chain contains only one certificate, it is not self-signed, and partial chains aren't allowed.
self-signed certificateThe passed certificate is self-signed and the same certificate cannot be found in the list of trusted certificates.
self-signed certificate in certificate chainThe chain could be built using the untrusted certificates, but no suitable trust anchor could be found in the trust store.
certificate has expiredThe notAfter date is before the current time.
hostname mismatchThe certificate doesn't match the requested host name.

OpenSSL notes that older versions of this documentation swapped the meanings of the first two errors, so older forum answers may describe them the other way round.

Why the chain matters

The TLS specifications say the server's certificate must come first in the list it sends, followed by the certificates that certify it: RFC 5246 (TLS 1.2) says each following certificate MUST directly certify the one preceding it, and RFC 8446 (TLS 1.3) says SHOULD. Both allow the root to be left out, because clients must already have it. So a correctly configured server sends the leaf plus every intermediate, and the root is optional.

OpenSSL builds the chain by looking for each issuer first in the trust store and then in the untrusted (intermediate) certificates it was given, and the chain has to end in a trust anchor. OpenSSL itself doesn't ship trust anchors; many Linux distributions provide a system default and configure OpenSSL to use it.

Why it works in a browser but fails in curl or an app: the nginx documentation explains that browsers usually store intermediate certificates they receive, so an actively used browser may already have the missing intermediate and not complain. Other clients, such as curl, scripts and mail servers, may not have it. Microsoft says Exchange Online doesn't fetch intermediate certificates on demand, and rejects or bounces mail with 450 4.4.317 UntrustedRoot when a remote mail server sends only its leaf certificate (see the 4.4.7 message expired guide).

Step 1: See what the server actually sends

openssl s_client -connect www.example.com:443 -servername www.example.com -showcerts

-showcerts displays the certificate list exactly as the server sent it, in order. OpenSSL stresses that this is not a verified chain. Look at the Certificate chain section: each entry shows the subject (s:) and issuer (i:). If there is only entry 0, and its issuer is an intermediate CA rather than a root you trust, the server isn't sending the intermediate.

For a mail server, add STARTTLS (OpenSSL supports smtp, pop3, imap, ftp, ldap and others):

openssl s_client -starttls smtp -connect mx.example.com:25 -servername mx.example.com -showcerts

s_client is a test tool: it continues the handshake after verification errors, so read the verification messages in its output, or add -verify_return_error to make it fail on them. Use -servername so a server hosting several sites returns the right certificate.

Step 2: Test the files you plan to install

openssl verify -show_chain -untrusted intermediate.pem server.pem
openssl x509 -in server.pem -noout -subject -issuer

-untrusted supplies intermediates for chain building, and -show_chain prints the chain that was built, flagging certificates that came from the untrusted list. If verification fails, openssl verify prints a line of the form error N at D depth lookup: followed by the error text, where depth 0 is the leaf, 1 is the CA that signed it, and so on. That tells you which link is missing. To test against a private CA, add -CAfile ca.pem.

Step 3: Fix the server (missing intermediate)

nginx

Concatenate the server certificate and the CA's bundle, server certificate first, and point ssl_certificate at the result:

cat www.example.com.crt bundle.crt > www.example.com.chained.crt
ssl_certificate     www.example.com.chained.crt;
ssl_certificate_key www.example.com.key;

If the order is wrong, nginx fails to start with a key values mismatch error, because it tried to use the private key with the bundle's first certificate.

Apache httpd

From version 2.4.8, the file in SSLCertificateFile can include the intermediate CA certificates after the leaf, sorted from leaf to root, which makes SSLCertificateChainFile obsolete. On older versions, put the CA certificates in SSLCertificateChainFile. Apache reads these files at startup, so restart it after the change.

Other servers and appliances

Load balancers, mail servers, Windows servers and appliances each have their own way to import an intermediate or full-chain certificate. Install the intermediate bundle your CA provides following the product's documentation, then repeat Step 1 against every IP address and port that serves the name.

Step 4: Fix the client (private or missing root)

Monitoring many certificates?

The Bulk SSL Certificate Expiry Monitor on Apify connects to each server and reads the certificate it is serving right now, on any port, including SMTP, IMAP and POP3 STARTTLS. It flags untrusted chains, hostname mismatches and weak keys, and can run on a schedule ($1 per 1,000 endpoints).

Related tools and guides

Check issued certificates and expiry dates with the SSL Certificate Checker (it reads Certificate Transparency logs, so pair it with the openssl command above for the chain a server actually serves), check a mail domain's MTA-STS policy with the MTA-STS Checker and its MX hosts with the MX Record Lookup, look up CAA and A records with DNS Lookup, confirm a change reached public resolvers with the DNS Propagation Checker and check forgotten names in the certificate with the Subdomain Takeover Checker. Related guides: SSL certificate has expired, SSL certificate name mismatch, Exchange Online 4.4.7 message expired, MTA-STS and TLS-RPT setup and self-signed certificate in certificate chain.

FAQ

What does unable to get local issuer certificate mean?

OpenSSL could not find the issuer of a certificate in the chain, so it could not build a path to a trusted root. Usually the server is not sending its intermediate certificate, or the client does not trust the root, for example a private CA.

How do I check whether a server sends the full certificate chain?

Run openssl s_client -connect host:443 -servername host -showcerts and read the Certificate chain section. It lists the certificates exactly as the server sent them. If only the leaf is there and its issuer is an intermediate CA, the intermediate is missing.

Why does the site work in my browser but curl says unable to get local issuer certificate?

The nginx documentation explains that browsers usually store intermediate certificates they have received before, so they can complete a chain the server did not send. curl, scripts and mail servers may not have it, so fix the server to send the intermediates.

Should I include the root certificate in the chain?

It is not needed. RFC 5246 and RFC 8446 allow the root to be omitted because clients must already have it. Send the server certificate first, followed by the intermediate certificates.

Is it safe to use curl -k or turn off certificate verification?

No. curl's documentation strongly recommends never skipping verification in production. Fix the server chain, or point the client at the correct CA with --cacert or the CA bundle environment variables.

Want the full kit?

Runbooks, checklists and helpdesk templates: IT Admin Packs on Gumroad.