【发布时间】:2017-09-18 08:29:40
【问题描述】:
在 android 中,我正在使用带有 HTTPS 协议的 RESTful API
HttpResponse response = null;
try {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI(UrlConnectionConstants.SCI_TA_AGENT_URL));
response = client.execute(request);
} catch (URISyntaxException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return response;
导致 SSLPeerUnverifiedException。
【问题讨论】:
-
我认为
HttpClient已被弃用,我建议您将HttpURLConnection用于http连接和HttpsURLConnection用于https连接更多信息stackoverflow.com/questions/22095813/… -
没有
SSLPeerUnspicifiedException。你的意思是SSLPeerUnverifiedException? -
感谢您的回复,但我对 HttpsURLConnection 类也有同样的问题
-
SSLPeerUnverifiedException
-
证书是服务器上的自签名证书吗?