HttpClient链接时,SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER提示已经废弃的替代方法

网上的很多老版本是这样的

 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext,
            new String[] {"TLSv1"}, null,
            SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);

源代码中已经废弃了

    /** @deprecated */
    @Deprecated
    public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;

新的一种方法。new DefaultHostnameVerifier()

 SSLConnectionSocketFactory sslcsf = new SSLConnectionSocketFactory(sslcontext,
                new String[] {"TLSv1"}, null,new DefaultHostnameVerifier());

或者 SSLConnectionSocketFactory.getDefaultHostnameVerifier()

SSLConnectionSocketFactory sslcsf = new SSLConnectionSocketFactory(sslcontext,
                new String[] {"TLSv1"}, null,SSLConnectionSocketFactory.getDefaultHostnameVerifier());

不过我不清楚这两个方法的区别。。。。。。望大神不吝赐教。

你可能感兴趣的:(微信,java)