Search code examples
phpandroidsslandroidhttpclient

Unable to upload strings with httpClient to my SSL server


I am trying to upload some text to my server using a php web service, with my server having an ssl certificate. When I try another server which doesn't have ssl, it works properly.

Can anyone help me in resolving this problem? I have spent all day searching in this forum.

Please don't tell me that it's repeated question (help that beginner programmer)

This is my code :

 protected String doInBackground(Void... params) {

        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("base64", ba1));
        nameValuePairs.add(new BasicNameValuePair("ImageName", System.currentTimeMillis() + ".jpg"));
        nameValuePairs.add(new BasicNameValuePair("arrondi",arrondi));
        nameValuePairs.add(new BasicNameValuePair("controleur",controleur));

        try {

            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(URL);
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
            HttpResponse response = httpclient.execute(httppost);
            String st = EntityUtils.toString(response.getEntity());
            Log.v("log_tag", "In the try Loop" + st);

        } catch (Exception e) {
            Log.v("log_tag", "Error in http connection " + e.toString());
        }
        return "Success";

    }

Solution

  • Please try to bypass SSL certificate and try again i think it should work.. How to bypass ssl certificate checking in java

    Android ignore self signed certificate