## 0x10 突然出现的 unrecognized_name
今天在使用httpclient
(Apache HttpComponents)访问https时候突然出现了一个戳手不及的错误
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name
嗯?然后在之前项目是没有问题的,最神奇的时候,有的https可以访问,有的不可以… 具体原因不是很清楚. 于是乎google了下,果不其然,在stackoverflow发现了 SSL handshake alert: unrecognized_name error since upgrade to Java 1.7.0这个问题,于是乎有了最暴力的解决方案:
设置jvm启动参数 java -Djsse.enableSNIExtension=false xxxx
或者直接使用java的进行设置:
System.setProperty("jsse.enableSNIExtension", "false");
然后你会发现,神奇的就好了.
java 7 introduced SNI support which is enabled by default. I have found out that certain misconfigured servers send an “Unrecognized Name” warning in the SSL handshake which is ignored by most clients… except for Java. As @Bob Kerns mentioned, the Oracle engineers refuse to “fix” this bug/feature.