创建一个混杂的HostnameVerifier,它接受所有主机名而无需进一步验证。
//来 自 N o w J a v a . c o m //package com.nowjava; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLSession; public class Main { /** * Creates a promiscuous {@link HostnameVerifier} that accepts all host * names without further verification. * * @return */ public static HostnameVerifier allowAllHostNames() { // Install host name verifier that always approves host names HostnameVerifier alwaysAllowHostVerifier = new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession sess