Java: SSLPeerUnverifiedException — Certificate for <host> doesn't match any of the subject alternative names
The TLS handshake worked, but Java's hostname verification found the certificate isn't valid for the requested host.
SSLPeerUnverifiedException: Certificate for <host> doesn't match any of the subject alternative namesjavax.net.ssl.SSLPeerUnverifiedException: Hostname not verifiedCertificate for doesn't match common name of the certificate subjecthostname in certificate didn't matchjava hostname verification failed Meaning
Connect using a name in the certificate's SAN (not an IP or alias), reissue the certificate with the right SANs, or fix the URL. Don't disable hostname verification in production (NoopHostnameVerifier).
Common causes
- Connecting by IP/alias not in the SAN
- Wrong or default certificate served
- Wildcard doesn't match deeper subdomain
- CN-only certificate
- Load balancer certificate mismatch
⚡ Quick fix
- Use the hostname from the certificate
- Reissue with correct SANs
- Check what's served:
openssl s_client -servername host
Detailed fix by platform
Shell
openssl s_client -connect host:443 -servername host </dev/null | openssl x509 -noout -ext subjectAltName
How to diagnose
- Host — In SAN?
- Connection — By IP?
- Cert — Right one?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- AH01909: server certificate does NOT include an ID which matches the server name Apache: [ssl:warn] AH01909: example.com:443:0 server certificate does NOT include an ID which matches the server name
- apex Wildcard certificate *.example.com doesn't cover example.com (the bare domain)
- cipher suites Java: SSLHandshakeException — no cipher suites in common (server side)
Most viewed in SSL / TLS
- HTTPSConnectionPool: Max retries exceeded (SSLError) Python requests: HTTPSConnectionPool(host='api.example.com', port=443): Max retries exceeded with url: /v1 (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] ...')))
- DST Root CA X3 expired (old clients fail) Old clients: certificate has expired — Let's Encrypt chain uses expired DST Root CA X3 (OpenSSL 1.0.x, Android < 7.1.1)
- SSLCertificateFile: file does not exist Apache: AH02240: Server should be SSL-aware but has no certificate configured / SSLCertificateFile: file '/etc/ssl/x.crt' does not exist or is empty
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026