对于我的开发机器,我想禁用对 HTTPS 连接的 SSL 主机名检查。调度代码的异常是这样的:
javax.net.ssl.SSLException: hostname in certificate didn't match: <localhost> != <*.mydomain.com> OR <*.mydomain.com> OR <mydomain.com>
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:228) ~[httpclient-4.1.3.jar:4.1.3]
at org.apache.http.conn.ssl.BrowserCompatHostnameVerifier.verify(BrowserCompatHostnameVerifier.java:54) ~[httpclient-4.1.3.jar:4.1.3]
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:149) ~[httpclient-4.1.3.jar:4.1.3]
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:130) ~[httpclient-4.1.3.jar:4.1.3]
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:397) ~[httpclient-4.1.3.jar:4.1.3]
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:148) ~[httpclient-4.1.3.jar:4.1.3]
我正在寻找一种方法来设置默认主机名验证器,以供调度使用。已弃用的 HttpsURLConnection 上有一种方法可以设置默认主机名验证程序,但整个类显然已弃用。目前有正确的方法来做到这一点吗?