javax.net.ssl.SSLException: hostname in certificate didn't match android

后端 未结 1 967
南旧
南旧 2020-12-29 14:48

I am creating an android app in which i am sending data to the web service but i am getting error of javax.net.ssl.SSLException: hostname in certificate didn\'t match androi

1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-29 15:31

    You can use SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER

    SSLSocketFactory sf = new SSLSocketFactory(
    SSLContext.getInstance("TLS"),
    SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
    Scheme sch = new Scheme("https", 443, sf);
    httpclient.getConnectionManager().getSchemeRegistry().register(sch);
    
    HttpGet httpget = new HttpGet("https://host/");
    

    Where you are trying to connect.

    0 讨论(0)
提交回复
热议问题