I have a problem of ssl exception when i upload data to a https server. It uploaded the data to the server correctly but when i get the response after uploading it throws an exception of ssl certificate is not trusted. I'm using the SAX parser for parsing xml file and i am using httppost method().
Asked
Active
Viewed 2,494 times
0
-
If your https server is not using an signed ssl certificate communicating with it will be very difficult – Janusz Aug 13 '10 at 16:01
-
Ya its very difficult but i have done yesterday night. Its take lots of time to doing this. if you want then send me the email id – Amit Thaper Aug 18 '10 at 04:46
2 Answers
1
you have to add a new scheme to accept Secure site connections
check this, and there you will find another useful sample without checking the cetificate...
-
I have seen this But it will only help if i want to get data from server not with posting data – Amit Thaper Aug 18 '10 at 04:47
0
Android comes with the apache commons http library included. Setting up a https post request is quite easy:
HttpPost post = new HttpPost("https://yourdomain.com/yourskript.xyz");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("postValue1", "my Value"));
nameValuePairs.add(new BasicNameValuePair("postValue2", "2nd Value"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
String responseText = EntityUtils.toString(entity);
Android uses a version 4.x of the commons http library as all versions below 4.0 are out of their lifecycle.
I can't tell exactly how to register a self-signed certificate to the HttpClient, but mybe the commons http documentation helps:
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e506

Manan Sharma
- 631
- 2
- 14
- 28