我们最近为我们的 Android 应用程序使用的网络服务应用了一个证书。
我已将 Web 服务的路径更改为 HTTPS,并且一切正常。不会抛出异常。
下面是我用来发布到网络服务的代码:
HttpParams httpParameters = new BasicHttpParams();
// CONNECTION TIMEOUT
int timeoutConnection = 15000;
HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
// SOCKET TIMEOUT
int timeoutSocket = 30000;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
DefaultHttpClient httpClient = new DefaultHttpClient(httpParameters);
HttpPost httpPost = new HttpPost(getWebServiceAddress() + actionName);
httpPost.addHeader("Content-Type", "application/json; charset=utf-8");
httpPost.addHeader("Accept-Encoding", "gzip");
httpPost.addHeader("User-Agent", "gzip");
httpPost.setEntity(new StringEntity(jsonBody, "UTF-8"));
HttpResponse response = null;
response = httpClient.execute(httpPost);
我的问题是:在不更改 Android 代码的情况下,我从应用程序传出的通信是否也安全?我是否必须对与 HTTPS 相关的代码进行任何更改才能强制加密?