[问题] 透过https方式post的问题

楼主: sweet00914 (别理我)   2014-09-11 14:24:42
有关于透过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();
楼主: sweet00914 (别理我)   2014-09-11 14:33:00
刚发现ROOT过的手机可以执行~但没有ROOT的就不行!
作者: gn00742754 (西门猫)   2014-09-12 09:01:00
是localhost吗?
作者: nobody1 (无事家中坐)   2014-09-12 09:46:00
google X509TrustManager

Links booklink

Contact Us: admin [ a t ] ucptt.com