HTTPS hostname wrong: should be . What causes this?

后端 未结 7 672
故里飘歌
故里飘歌 2020-12-03 10:38

I am getting this \'HTTPS hostname wrong:\' error when trying to connect to a server using https. My url looks something like this

https://sub.domain.com/tam         


        
7条回答
  •  醉梦人生
    2020-12-03 11:04

    The following code resolved my problem

    static {
        //for localhost testing only
        javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
                new javax.net.ssl.HostnameVerifier() {
    
            @Override
            public boolean verify(String hostname,
                    javax.net.ssl.SSLSession sslSession) {
                if (hostname.equals("your_domain")) {
                    return true;
                }
                return false;
            }
        });
    }
    

提交回复
热议问题