【发布时间】:2015-01-29 13:01:12
【问题描述】:
我有一个 android 应用程序,它在服务器上调用一些 php 脚本,并通过使用“普通”HTTP 连接接收 json 消息作为响应:
static JSONObject jObj = null;
static String json = "";
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
jObj = new JSONObject(json);
//code for parse jObj Object
现在我需要将整个服务器转移到使用 ssl 加密数据的新服务器上。在开始服务器迁移之前,我需要知道如何修改我的 android 源以通过 https 使用它。 只需要用https修改脚本地址(HttpPost会自动管理所有https阶段),还是需要做其他实质性修改?
【问题讨论】:
-
你只需要把url改成https://
-
对我来说,它适用于网址中的 https://
-
so HttpPost 自动协商密钥并选择加密算法?