Michał Tajchert
Michał Tajchert

Reputation: 10383

SSL on Android <3.0

I would like to parse JSON which is secured with SSL (https), and on Android 2.x I obtain: "No Peer Certificate Exception", and I don't know (almost) anything about certificates, can somebody explain how to step by step how to integrate SSL certificate to my app and use it (which I understand I had to). Thats my current code:

HttpGet httppost =  new HttpGet(url);
httppost.setHeader("Content-type", "application/json");
response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
inputStream = entity.getContent();

Upvotes: 0

Views: 154

Answers (1)

Robert
Robert

Reputation: 42615

The exception means that the device does not trust the certificate of your server. If the used server certificate is a paid one (bought by a trustcenter) this means that the trustcenter certificate is not present on that device.

You can add the trustcenter certificate (or a self-signed certificate) into your app by placing it into a BouncyCastle Keystore (BKS)

Note that the latest versions of BouncyCastle produce by default a BKS file of a newer version that can not be read by Android. You need BouncyCastle 1.46.

See also: http://randomizedsort.blogspot.de/2010/09/step-to-step-guide-to-programming.html

Upvotes: 1

Related Questions