I have a certificate to secure my site, certified by: Thawte DV SSL CA, Thawte, Inc.
Now I made an android application that connects to a webservice from this site. It used to work fine when just going for http://www.myserver.com.
But now that it's secured, and going for https://www.myserver.com I'm having some issues.
I use 2 phones to test my application.
HTC Desire S with Android 2.3.3 (has SD card)
Huawei Ideos X5 with Android 2.2.1 (no SD card)
The HTC does not have any problem connecting to the https. The Huawei however gives a "Not trusted certificate exception".
The code I used to try and connect is the following:
public String performRequest(String message, String url, Context context) throws IOException {
AndroidHttpClient hc = AndroidHttpClient.newInstance("Android",context);
Log.d(MobileConnectorApplication.APPLICATION_TAG, "NETWORK - Message to send: "+ message);
HttpPost p = new HttpPost(url);
HttpParams httpParams = new BasicHttpParams();
HttpConnectionParams.setSoTimeout(httpParams, threeMinutes );
p.setParams(httpParams);
try{
if (message != null)
p.setEntity(new StringEntity(message, "UTF8"));
}catch(Exception e){
e.printStackTrace();
}
p.setHeader("Content-type", "application/json");
String response = "";
HttpContext httpcontext = new BasicHttpContext();
httpcontext.setAttribute(ClientContext.COOKIE_STORE, MobileConnectorApplication.COOKIE_STORE);
try{
HttpResponse resp = hc.execute(p,httpcontext);
InputStream is = resp.getEntity().getContent();
response = convertStreamToString(is);
int httpResponsecode = resp.getStatusLine().getStatusCode() ;
checkResponse(url, message, response, httpResponsecode);
Log.d(MobileConnectorApplication.APPLICATION_TAG, String.format("NETWORK - Response %s : %s", httpResponsecode, response.length() > 150 ? response.subSequence(0, 150): response));
} finally{
hc.close();
}
return response;
}
This part of the code was made by someone else a few months ago and he isn't around to change it and my knowledge about these connections isn't so great.
could someone help me out? Thanks in advance!