0

I am using below code for server connection

    HttpResponse response = null;
    // Creating HTTP client
    HttpClient httpClient = new DefaultHttpClient();
    // Creating HTTP Post
    HttpEntity entity = null;
    String data = null;
    // Making HTTP Request
    try {
        if (method == KEY_GET) {
            HttpGet httpget = new HttpGet(url);
            response = httpClient.execute(httpget);
        } else if (method == KEY_POST) {
            HttpPost httpPost = new HttpPost(url);
            httpPost.addHeader("Content-Type", "application/json;    charset=utf8");
            httpPost.addHeader("Accept", "application/json");
            //convert parameters into JSON object
            StringEntity se = null;
            //passes the results to a string builder/entity
            try {
                se = new StringEntity(postParameter.toString());
            } catch (Exception e) {

            }
            //sets the post request as the resulting string
            httpPost.setEntity(se);
            response = httpClient.execute(httpPost);
        }
        entity = response.getEntity();
        data = EntityUtils.toString(entity);
    } catch (ClientProtocolException e) {
        // writing exception to log
        e.printStackTrace();
    } catch (IOException e) {
        // writing exception to log
        e.printStackTrace();

    } catch (Exception e2) {
        e2.printStackTrace();
    }

Earier it was working for all requests. But now after Implementing SSL on server its giving me "javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found." error.

How can I resolve it?

Thanks in advance

unflagged.destination
  • 1,576
  • 3
  • 19
  • 38
  • Have you already read http://stackoverflow.com/questions/21183043/sslhandshakeexception-trust-anchor-for-certification-path-not-found-android-http ? – Little Santi Nov 14 '16 at 09:32
  • Possible duplicate of [Android self signed certificate: Trust anchor for certification path not found](http://stackoverflow.com/questions/18959663/android-self-signed-certificate-trust-anchor-for-certification-path-not-found) – user207421 Nov 14 '16 at 09:41
  • you need either a valid SSL on the server-side, or a custom SSL verifier on the client side. – Vladyslav Matviienko Nov 14 '16 at 09:47

0 Answers0