# Java: SSLPeerUnverifiedException — Certificate for <host> doesn't match any of the subject alternative names

**Code:** `hostname` · **Category:** SSL / TLS · **Seen on:** Java, SSL

The TLS handshake worked, but Java's hostname verification found the certificate isn't valid for the requested host.

## 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

1. Use the hostname from the certificate
2. Reissue with correct SANs
3. Check what's served: `openssl s_client -servername host`

## Detailed fix by platform

### Shell

1. `openssl s_client -connect host:443 -servername host </dev/null | openssl x509 -noout -ext subjectAltName`

## How to diagnose

1. **Host** — In SAN?
2. **Connection** — By IP?
3. **Cert** — Right one?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/ssl/java-hostname-verification-failed-sslpeerunverifiedexception)
