Wednesday, May 7, 2014

SSL handshake alert: unrecognized_name error with Apache and Java 7

When running a web application involving HTTPS and Java, you may see a Server Name Indication error, perhaps after upgrading to JRE7:

javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name

If you're also running Apache, perhaps as a proxy server, one quick thing to check:
Make sure your ServerName is set in the Apache httpd configuration [httpd.conf] for the relevant VirtualHost entries.

The short explanation is that JRE7 is a bit stricter than previous versions and Java with respect to security and verification. In this case, ServerName is required while SNI is enabled.

After recently encountering this error, much time was spent browsing various search engine results to no avail, until finally a page was found mentioning the ServerName item -- indeed, the Apache configuration was missing it. Problem solved.