How to Solve SSL javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

Viewed 816

I have some problem in

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

I use volley library for my application.

It is self sign and self generated certificate

Here is part of my code;

public class MainActivity extends AppCompatActivity{

Button button;
TextView textView;
RequestQueue requestQueue;
String url="https://www.xxxxxx.xxxx/xxxxxx/xxx/xxxxxx/xxxxx";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    requestQueue= Volley.newRequestQueue(this);
    button=(Button)findViewById(R.id.btn_get_repos);

    textView=(TextView)findViewById(R.id.tv_repo_list);
    button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
        final StringRequest stringrequest = new StringRequest(Request.Method.GET, url,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String s){
                        Log.e("Response",s);
                        textView.setText(s); 
                        Log.e("Json response:", requestQueue.toString());
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                error.toString();
                Toast.makeText(getApplicationContext(),error.getMessage(), Toast.LENGTH_LONG).show();
                Log.e("onErrorResponse",error.getMessage());
            }
        }){
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                headers.put("Content-Type", "application/json;charset=utf-8");
                headers.put("Accept", "application/json");
                headers.put("Authorization", "xxxx xxxxxxxxxxxxxxx");

                return headers;
            }

        };
        requestQueue.add(stringrequest);
    }
  });
 }
}

I'm trying to see the response from server but not able to hit.

Please help me out!

0 Answers
Related