Search code examples
androidandroid-asynctaskhttpurlconnectionhttpsurlconnection

HttpsURLConnection error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found


Previously, our website was Http and I used AsyncTask and HttpURLConnection to post data with API but now it is Https and when I convert HttpURLConnection to HttpsURLConnection I got this error:

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

What should I do?


Solution

  • To identify the issue, as I mentioned, firstly try ignoring certificate using TrustManager .if it works then check with the server if it accepts self-signed or which parent certificate. In General, devices already come with preloaded certificates by the majority CA .Here is a detailed link .