【发布时间】:2014-10-20 10:12:56
【问题描述】:
当连接到 HTTPS 后端时,来自 Android 中可用的 apache 库的常规 HTTP 调用是否会产生安全通信?
因为端点是 HTTPS,并且假设后端是安全的,这是从 Android 客户端发送密码的有效方式吗?请注意,在下面的代码中,密码被插入到 POST 请求的正文中,并且没有加密。
我的代码如下:
// Create post
String url = "https://example.endpoint.com/token";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
HttpResponse response = null;
HttpEntity entity = null;
// Populate the post request
JSONObject json = new JSONObject();
json.put("username", user);
json.put("password", pass);
StringEntity se = new StringEntity( json.toString() );
se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
post.setEntity(se);
// Execute the post request
response = client.execute(post);
使用的库有:
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicHeader;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
【问题讨论】:
标签: java android apache ssl https