3

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!

  • D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true E/onErrorResponse: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. – Ashwath.joshi Aug 07 '17 at 10:26
  • Is this your server, or somebody else's? – CommonsWare Aug 07 '17 at 10:46
  • I believe this should be from the server side, where the ssl certificate is not signed so the android client doesn't trust the apis exposed by the server. It is not advised to use trust managers to trust all certificates. – SripadRaj Aug 07 '17 at 12:12
  • Possible duplicate of [SSLHandshakeException Trust anchor for certification path not found Android HTTPS](https://stackoverflow.com/questions/21183043/sslhandshakeexception-trust-anchor-for-certification-path-not-found-android-http) – Stewart Feb 12 '18 at 14:48

0 Answers0