Lesson 13 of 16 · HTTPS and certificates
Fixing common TLS errors
A field guide to the TLS errors you will actually see in browsers, curl, Java and Python: what each one means, how to confirm it with one or two commands, and the real fix. Name mismatch, unknown issuer, missing intermediate, expired or not-yet-valid (often a wrong clock), corporate TLS inspection, and protocol or port mistakes.
The first two commands
For almost any TLS problem, start here:
$ curl -v https://host 2>&1 | grep -E "SSL|subject|issuer|expire|error"
$ openssl s_client -connect host:443 -servername host -showcerts </dev/null
The s_client output shows every certificate the server sends (s: subject, i: issuer for each) and ends with a Verify return code, for example 0 (ok) or 20 (unable to get local issuer certificate). Always pass -servername, or a server hosting many sites may send the wrong certificate.
The field guide
1. Name mismatch
Browser: NET::ERR_CERT_COMMON_NAME_INVALID
curl: SSL: no alternative certificate subject name matches target host name 'api.example.com'
Java: No subject alternative DNS name matching api.example.com found
The hostname you used is not in the certificate's SAN list. Check the SANs (-ext subjectAltName). Common causes: example.com missing from a *.example.com certificate, connecting by IP, the wrong virtual host answering, a new subdomain not added. Fix: reissue with the right SANs, or use the right name.
2. Unknown issuer / missing intermediate
Browser: NET::ERR_CERT_AUTHORITY_INVALID
curl: SSL certificate problem: unable to get local issuer certificate
Java: PKIX path building failed … unable to find valid certification path
Python: CERTIFICATE_VERIFY_FAILED
Either the server sends only its leaf (look at s_client -showcerts: only one certificate?), or the issuing CA is private and not in this client's trust store (lesson 9), or the container image has no CA bundle. Fix: serve fullchain.pem; or add the private CA to the client's trust store (update-ca-certificates, Java keytool, REQUESTS_CA_BUNDLE for Python); or install ca-certificates in the image.
3. Self-signed in the chain
curl: SSL certificate problem: self-signed certificate in certificate chain
Often a corporate TLS inspection proxy: it decrypts and re-signs traffic with the company's own CA. Check the issuer: if it's the company's proxy, install the company's CA in the client's trust store. Otherwise it's a private CA that needs trusting.
4. Expired, or not yet valid
Browser: NET::ERR_CERT_DATE_INVALID
curl: SSL certificate problem: certificate has expired
SSL certificate problem: certificate is not yet valid
Check the dates (-dates). If one site fails, renew it (lesson 12), and check whether an intermediate expired too. If every site fails on one machine, the client clock is wrong: check timedatectl and fix NTP. Devices with dead clock batteries often show this.
5. Wrong port or protocol
curl: (35) … wrong version number
TLS was spoken to something answering in plain HTTP (for example https://host:80), or a proxy in between. Use the right port, or http://.
6. No common protocol or cipher
… handshake failure / unsupported protocol / no protocols available
One side only allows old versions (an old device with TLS 1.0) or only new ones. Test with openssl s_client -tls1_2 / -tls1_3. Fix: upgrade the old side. Re-enabling old TLS versions on a server should be a last, temporary resort.
7. Client certificate required (mTLS)
… alert certificate required / handshake failure after CertificateRequest
The server wants a client certificate (mTLS). Pass one with curl --cert client.crt --key client.key, and check it has clientAuth in its EKU and is signed by a CA the server trusts.
TLS errors are the bouncer at a club explaining why you can't come in. "Name's not on the list" (name mismatch). "Never heard of whoever signed your ID" (unknown issuer). "Your ID ran out last week" (expired), or your watch is wrong about what day it is (clock). Read what the bouncer says; it nearly always tells you exactly what's wrong.
What not to do
- Don't add
-k,verify=FalseorInsecureSkipVerifyto make it go away; that removes every check (lesson 10). - Don't paste a private key into an online "certificate checker".
- Don't renew blindly: if the problem is a missing intermediate or a client trust store, a new certificate changes nothing.
Quick decision table
| Symptom | Check | Usual fix |
|---|---|---|
| Name error | SAN list | Reissue with the right names |
| Unknown issuer, browser OK | -showcerts shows 1 cert |
Serve full chain |
| Unknown issuer everywhere | Issuer is private or proxy | Add CA to trust store |
| Expired, one site | -dates |
Renew, reload, automate |
| Expired, every site | timedatectl |
Fix client clock / NTP |
| Wrong version number | Port and scheme | Use the TLS port |
| Handshake failure | Versions both sides | Upgrade the old side |
Recap
- Start with
curl -vandopenssl s_client -servername … -showcerts; read the verify code. - The big four: name mismatch, unknown issuer or missing intermediate, expired (or wrong clock), wrong port.
- Fix the cause (names, chain, trust store, clock); never switch verification off.
This site is a public version of my personal engineering knowledge hub. It intentionally excludes confidential company information and internal operational details.