作者sweet00914 (别理我)
看板AndroidDev
标题[问题] 透过https方式post的问题
时间Thu Sep 11 14:24:42 2014
有关於透过https 来post
首先我参考
http://stackoverflow.com/questions/2642777/trusting-all-certificates-using-httpclient-over-https
的方式,来自定义SSLSocketFactory
接着在主要POST的程式中
HttpClient httpclient = new DefaultHttpClient();
httpclient=MySSLSocketFactory.createMyHttpClient();
HttpPost httpPost = new HttpPost("
https://xxxx");
StringEntity se = new StringEntity("paramterXXX",
HTTP.UTF_8);
httpPost.setEntity(se);
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "text/json");
// 8. Execute POST request to the given URL
HttpResponse httpResponse = httpclient.execute(httpPost);
// 9. receive response as inputStream
inputStream = httpResponse.getEntity().getContent();
------------------------------------------------------------------------
程式执行到 HttpResponse httpResponse = httpclient.execute(httpPost);
就停住了!接着回报错误
org.apache.http.conn.HttpHostConnectException: Connection to
https://xxxx refused
请问大家知道该如何解决呢?
谢谢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 211.72.185.162
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/AndroidDev/M.1410416685.A.F29.html
1F:→ sweet00914: 刚发现ROOT过的手机可以执行~但没有ROOT的就不行! 09/11 14:33
2F:推 gn00742754: 是localhost吗? 09/12 09:01
3F:→ nobody1: google X509TrustManager 09/12 09:46