[問題] 透過https方式post的問題

看板AndroidDev作者 (別理我)時間9年前 (2014/09/11 14:24), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/1
有關於透過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://www.ptt.cc/bbs/AndroidDev/M.1410416685.A.F29.html

09/11 14:33, , 1F
剛發現ROOT過的手機可以執行~但沒有ROOT的就不行!
09/11 14:33, 1F

09/12 09:01, , 2F
是localhost嗎?
09/12 09:01, 2F

09/12 09:46, , 3F
google X509TrustManager
09/12 09:46, 3F
文章代碼(AID): #1K4K0jyf (AndroidDev)