I tried to make a secure connection between my Android App and the PHP Server via SSL and Post. However it's unfortunately not connecting to the Server, because the SSL certificate can't be verified.
HttpPost httppost = new HttpPost("https://example.me/api/index.php");
returns:
javax.net.ssl.SSLExeption: hostname in certificate didn't match: <example.me> != <*.one.com> OR <*.one.com> or <one.com>
Is there a workaround for this problem, with which I can manualy verify it? Because
HttpPost httppost = new HttpPost("http://example.me/api/index.php");
is working like a charm :/
Full Code:
public static String[] getList(String user, String pass, String addArray, String removeArray){
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://example.me/api/index.php");
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("user", user));
nameValuePairs.add(new BasicNameValuePair("pass", pass));
nameValuePairs.add(new BasicNameValuePair("addArray", addArray));
nameValuePairs.add(new BasicNameValuePair("removeArray", removeArray));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
ResponseHandler<String> responseHandler = new BasicResponseHandler();
String ResponseBody = httpclient.execute(httppost, responseHandler);
if(ResponseBody!=null){
String[] list = ResponseBody.split( Pattern.quote( ";" ) );
return list;
}else{
String[] error = {"empty"};
return error;
}
} catch (ClientProtocolException e) {
String[] error = {e.toString()};
return error;
} catch (IOException e) {
String[] error = {e.toString()};
return error;
}
}
Thanks for your help ;)
(I replaced my DNS with example.me)