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

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

以前,我们的网站是 Http,我使用 AsyncTask 和 HttpURLConnection 来 post 数据 API,但现在它是 Https,当我将 HttpURLConnection 转换为 HttpsURLConnection 时,我得到了这个错误:

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

我该怎么办?

要确定问题,正如我提到的,首先尝试使用 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 .

忽略 certificate