集册 Java实例教程 创建一个混杂的HostnameVerifier,它接受所有主机名而无需进一步验证。

创建一个混杂的HostnameVerifier,它接受所有主机名而无需进一步验证。

欢马劈雪     最近更新时间:2020-01-02 10:19:05

552
创建一个混杂的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
展开阅读全文