0

i have a java class used for invoke php POST scripts on server, and parse response (a json message). this is code for send request and get response:

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();
return  new JSONObject(json);

and on PHP script i get params with

$_POST['params'];

and send result with

json_encode($response_json);

now, url is a simple http. Now i would buy an ssl certificate for my server (a cloud hosting) for crypt data (sended and received).

How i should modify my android and php code for send request and read values in https? does android api automatically crypt data with ssl or not?

giozh
  • 9,868
  • 30
  • 102
  • 183
  • Take a look at here `http://stackoverflow.com/questions/7622004/android-making-https-request`. It'll give you an idea of wat u need to do :-/ – Panther Oct 20 '14 at 08:42
  • so i need to instance SSL connection manually each time? because here https://developer.android.com/training/articles/security-ssl.html tutorial cal only OpenConnection with https url (if CA is well known) – giozh Oct 20 '14 at 09:04

0 Answers0