Skip to content
RU

javax.net.ssl.SSLPeerUnverifiedException: Hostname Not Verified or Pinning Failure

What it means: Java could not confirm the server's identity: the name, the pin or the certificate itself is missing.

  1. Read the exception message
  2. Compare host name with the certificate SANs
  3. Pinning failure: update pins after rotation
  4. Peer not authenticated: debug the handshake

Test your URL now

Runs a full TLS check: handshake, protocol versions, certificate chain, trust and expiry.

Check your site's SSL →

What SSLPeerUnverifiedException means

javax.net.ssl.SSLPeerUnverifiedException is a subclass of SSLException that, in the Java documentation's words, «indicates that the peer's identity has not been verified» (Java SE API). Unlike PKIX path building failed, which says the certificate chain is not trusted, this exception is thrown when trust in the chain is not the question: the certificate is for another name, does not match a pin, or was never received.

Three messages cover almost every report:

  • Hostname example.com not verified: followed by the certificate pin, DN and subjectAltNames — OkHttp's host name check (OkHttp ConnectPlan). Apache HttpClient 4.5 says Certificate for <example.com> doesn't match any of the subject alternative names: [...].
  • Certificate pinning failure! followed by Peer certificate chain: and Pinned certificates for example.com: — OkHttp's CertificatePinner found no pin that matches the chain.
  • peer not authenticated — thrown by the JDK when code asks SSLSession.getPeerCertificates() on a session that has no peer certificates, typically because the handshake did not complete (SSLSessionImpl).

Causes by message

MessageCauseFix
Hostname ... not verified / doesn't match any of the subject alternative namesCalling the server by IP, an internal alias or a name the certificate does not listUse a listed name or reissue the certificate with the name in SAN
Same, only for some usersWrong virtual host answered: SNI not sent, or DNS points to another serverSend the right host name; check DNS
Certificate pinning failure!The server's key or CA changed and the app pins the old oneShip updated pins; pin with a backup
peer not authenticatedHandshake failed silently (protocol or cipher mismatch, client certificate required) and code read the session anywayEnable handshake debugging, fix the TLS settings

Check the name against the certificate's subjectAltName list, which is what modern clients and the CA/Browser Forum rules rely on; do not count on a name that appears only in the Common Name. The host name in the URL is what is checked, so a request to https://203.0.113.10/ fails against a certificate for api.example.com even when that is the right server. A wildcard covers one label: *.example.com matches api.example.com but not example.com or a.b.example.com.

Diagnose it

List the names the server's certificate actually covers, sending the same SNI your app sends:

openssl s_client -connect api.example.com:443 -servername api.example.com </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -ext subjectAltName
keytool -printcert -sslserver api.example.com:443 | grep -A3 SubjectAlternativeName

For peer not authenticated, turn on the JSSE debug log for one run and read the last messages before the failure:

java -Djavax.net.debug=ssl:handshake -jar app.jar

For a pinning failure, compute the pin of what the server presents now and compare it with the pins in your code. OkHttp pins are sha256/ plus the base64 SHA-256 of the certificate's public key info:

openssl s_client -connect api.example.com:443 -servername api.example.com </dev/null 2>/dev/null \
  | openssl x509 -pubkey -noout | openssl pkey -pubin -outform der \
  | openssl dgst -sha256 -binary | openssl enc -base64

The OkHttp exception prints the same hashes for every certificate in the chain, so you can also copy them from the stack trace.

How to fix it

  1. Name mismatch: connect with a host name that the certificate lists. If you must reach a server by an internal name or IP, issue a certificate that contains it (an IP needs an IP-address SAN). Do not replace the verifier with NoopHostnameVerifier or a HostnameVerifier that returns true; that accepts a valid certificate for any other site.
  2. Wrong server answered: make sure the client sends SNI for the host name (it does when you use the name, not the IP, in the URL) and that DNS resolves to the right machine.
  3. Pinning failure after a certificate renewal: pin the public key of an intermediate or root you control the change of, include at least one backup pin, and update the app before you rotate keys. Re-using the same key on renewal keeps leaf pins valid.
  4. peer not authenticated: fix the handshake the debug log shows: enable TLS 1.2/1.3 on the server or upgrade an old JDK, or provide the client certificate the server requires.
  5. Untrusted chain instead: if the log shows PKIX path building failed earlier, follow the PKIX page: that is a trust store problem, not a name problem.

How to confirm the fix

openssl s_client -connect api.example.com:443 -servername api.example.com -verify_hostname api.example.com </dev/null 2>/dev/null | grep 'Verify return code'
# Verify return code: 0 (ok)

-verify_hostname makes OpenSSL apply the same name check your Java client does. The SSL/TLS checker shows the certificate names and chain your server presents from outside.

Related errors

CertificateExpiry, issuer, domains (SAN)
ChainIntermediate and root CA validation
TLS ProtocolTLS version and cipher suite
VulnerabilitiesHeartbleed, POODLE, weak ciphers

Why teams trust us

TLS 1.3
supported
Full
CA chain check
3,158
checks in 30 days
30/14/7
days-to-expiry alerts

How it works

1

Enter domain

2

TLS chain verified

3

Expiry date & vulnerabilities

What Does the SSL Check Cover?

SSL/TLS is the encryption protocol that protects data between the browser and server. Our tool analyzes the certificate, chain of trust, TLS version, and knownvulnerabilities.

Certificate Details

Issuer, validity period, signature algorithm, covered domains (SAN), and validation type (DV/OV/EV).

Chain of Trust

Full chain verification: from leaf certificate through intermediates to root CA.

TLS Analysis

Protocol version (TLS 1.2/1.3), cipher suites, Perfect Forward Secrecy (PFS) support.

Expiry Alerts

Set up a monitor — get Telegram and email alerts 30/14/7 days before expiration.

DV vs OV vs EV Certificates

DV (Domain Validation)
  • Confirms domain ownership only
  • Issued in minutes automatically
  • Free via Let's Encrypt
  • Suitable for most websites
  • Most common certificate type
OV / EV
  • Organization (OV) or Extended Validation (EV)
  • Issued in 1-5 business days
  • Costs $50 to $500/year
  • For finance, e-commerce, government sites
  • Increases user trust

Who uses this

DevOps

SSL certificate monitoring

Security

TLS config audit

SEO

HTTPS as ranking factor

E-commerce

customer trust

Common Mistakes

Expired certificateBrowsers block sites with expired SSL. Set up auto-renewal or monitoring.
Incomplete certificate chainWithout intermediate CA, some browsers and bots cannot verify the certificate.
Mixed content on HTTPS siteHTTP resources on an HTTPS page — the browser lock icon disappears, reducing trust.
Using TLS 1.0/1.1Legacy TLS versions have known vulnerabilities. Use TLS 1.2+ or 1.3.
Domain mismatch in certificateThe certificate must cover all site domains, including www and subdomains.

Best Practices

Set up auto-renewalLet's Encrypt + certbot with cron — certificate renews automatically every 60-90 days.
Enable HSTSStrict-Transport-Security header forces browsers to always use HTTPS.
Use TLS 1.3TLS 1.3 is faster (1-RTT handshake) and safer — legacy ciphers removed.
Monitor expiration datesCreate a monitor on Enterno.io — get notified well before expiration.
Verify chain after renewalAfter certificate renewal, confirm that intermediate certificates are installed.

Get more with a free account

SSL certificate monitoring, check history and alerts 30 days before expiry.

Sign up free

Learn more

Sources

Frequently Asked Questions

What is the difference between SSLPeerUnverifiedException and PKIX path building failed?

PKIX path building failed means Java does not trust the certificate chain. SSLPeerUnverifiedException means the identity check failed: wrong host name, a failed pin, or no peer certificate at all.

What does peer not authenticated mean in Java?

Code asked the TLS session for the server's certificates, but the session has none, usually because the handshake failed. Run with -Djavax.net.debug=ssl:handshake to see why.

How do I fix OkHttp Certificate pinning failure!?

The server now presents a key that none of your pins match, typically after a certificate change. Add the new pin printed in the exception, keep a backup pin, and release the update before rotating keys.

Can I disable host name verification to make it work?

You can, but then any valid certificate for any domain is accepted, which defeats TLS. Fix the name in the URL or in the certificate instead.

Try the live tool that powered this guide

Free plan — 10 monitors, checks every 5 min, no card required. Upgrade for 1-minute interval and multi-region monitoring.