Hostname was not verified ANDROID

前端 未结 2 1531
北海茫月
北海茫月 2021-01-25 09:54

I am using ksoap lib to call the webservice . In some cases service run correctly but in a case it gives Host name was not verified below is my code f

2条回答
  •  攒了一身酷
    2021-01-25 10:13

    Verify your host as

       HttpsURLConnection.setDefaultHostnameVerifier(new HostVerifier());
    
    
     public class HostVerifier implements HostnameVerifier {
    
    @Override
    public boolean verify(String hostname, SSLSession session) {
        Log.i(TAG, "HOST NAME " + hostname);
        if (hostname.contentEquals("XXX.XX.XXX.XXX")) {
            Log.i(TAG, "Approving certificate for host " + hostname);
            return true;
        }
        return false;
     }
    }
    

提交回复
热议问题