java.io.IOException: Hostname was not verified

后端 未结 10 617
逝去的感伤
逝去的感伤 2020-11-28 06:27

I am trying to connect to a URL from a my Android app in Andorid Version 4.1.1, and I get the error indicated in the Title of my question, but when I tried to connect the sa

10条回答
  •  一向
    一向 (楼主)
    2020-11-28 07:13

    Please note SSL Certificate work only by Domain not work by IP address.

    if you use IP ,insert below code

    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier()
            {
                @Override
                public boolean verify(String hostname, SSLSession session)
                {
                    if(hostname.equals("127.0.0.1"))
                         return true;
                }
            });
    

提交回复
热议问题