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

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.