android 基于https协议(HttpsURLConnection)的网络访问:
由于HttpsURLConnection是HttpURLConnection的子类,在这里就不多作介绍了,
如果需要,可直接把下面的HttpURLConnection改成HttpsURLConnection即可(当前
项目中是http、https都可以访问,所以采用的是HttpURLConnection)
在这里值得注意的是:
1. 本人没用研究过X509HostnameVerifier这个接口,就直接重写了X509HostnameVerifier这个接口,
把它唯一的方法写为空,直接return ture;结果一直抛:CertificationException: Trust anchor
由于HttpsURLConnection是HttpURLConnection的子类,在这里就不多作介绍了,
如果需要,可直接把下面的HttpURLConnection改成HttpsURLConnection即可(当前
项目中是http、https都可以访问,所以采用的是HttpURLConnection)
在这里值得注意的是:
1. 本人没用研究过X509HostnameVerifier这个接口,就直接重写了X509HostnameVerifier这个接口,
把它唯一的方法写为空,直接return ture;结果一直抛:CertificationException: Trust anchor