Saltar al contenido
ecdsa.com
Java (JSSE)Java

Mensaje de error

javax.net.ssl.SSLHandshakeException: (unrecognized_name) Received fatal alert: unrecognized_name

También se muestra como

  • Received fatal alert: unrecognized_name

JDK 25 notifica «(unrecognized_name) Received fatal alert: unrecognized_name». Java 7 y las primeras versiones de Java 8 también abortaban cuando un servidor enviaba esta alerta solo como advertencia, un clásico con configuraciones de Apache httpd sin un ServerName que coincida.

Java (JSSE) — TLS alert 112 from a server that does not serve the requested SNI name

Qué significa

La JVM envió como SNI el nombre de host de la URL, y el servidor respondió con la alerta TLS 112 (unrecognized_name) como alerta fatal porque no tiene ningún sitio configurado para ese nombre. Java trata la alerta como fatal y se detiene. El servidor es accesible; simplemente no reconoce el nombre con el que te conectas.

Por qué ocurre

Cómo solucionarlo

  1. 1.

    Averiguar qué nombres acepta el servidor

    Prueba el handshake con los nombres candidatos usando openssl s_client -servername.

    bash
    # Which SNI names does the server accept?
    for n in api.example.com www.example.com; do
      printf '%-18s ' "$n"
      echo | openssl s_client -connect api.example.com:443 -servername "$n" -brief 2>&1 | grep -m1 -E 'Protocol version|alert' || echo fail
    done
  2. 2.

    Añadir el nombre al servidor

    Configura ServerName o ServerAlias (o su equivalente en nginx, en la CDN o en la plataforma) junto con un certificado que cubra ese nombre.

    text
    # Apache httpd: every name clients use must be a ServerName or ServerAlias of a TLS vhost
    <VirtualHost *:443>
        ServerName  api.example.com
        ServerAlias api-legacy.example.com
        SSLEngine on
    </VirtualHost>
  3. 3.

    Usar el nombre de host configurado

    Mejor corregir la URL que desactivar el SNI de forma global.

    text
    Use the server's configured host name in the URL. Turning SNI off with
    -Djsse.enableSNIExtension=false only works if the server's default site is the one you need,
    and it breaks every server that relies on SNI; avoid it.

Errores relacionados

Explorar toda la base de datos de errores de firma