In my Android application I use http link for get JSON response from server, now they changed to https. My code is return No peer certificate exception.
What the things need to get response from server using https in Android. This is the code I used for get response from server for http.
public static DefaultHttpClient httpClient;
public static ResponseHandler<String> resHandler;
public static List<NameValuePair> nameValuePairs;
public static HttpPost httpPost;
....
httpClient = new DefaultHttpClient();
resHandler = new BasicResponseHandler();
httpPost = new HttpPost("https://www.xxx.com/.../user/renting");
nameValuePairs = new ArrayList<NameValuePair>(6);
nameValuePairs.add(new BasicNameValuePair("parking_spot_id".trim(),
spotID));
....
for (int i = 0; i < array.length; i++) {
nameValuePairs.add(new BasicNameValuePair("date[]", array[i]));
}
try {
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
jsonResponse = httpClient.execute(httpPost, resHandler);
Log.e("rent by day", jsonResponse);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
The above code working well for using http.
1) What are the things I need to get for https.
2) What are the changes in the code.
Please help me.