0

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().

Janusz
  • 187,060
  • 113
  • 301
  • 369
Amit Thaper
  • 21
  • 2
  • 6
  • 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 Answers2

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...

Https Connection Android

Community
  • 1
  • 1
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
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