且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何忽略 PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException?

更新时间:2021-10-24 02:47:13

如果您想一起忽略证书,请查看此处的答案:忽略使用 Jersey 客户端的自签名 ssl 证书

If you want to ignore the certificate all together then take a look at the answer here: Ignore self-signed ssl cert using Jersey Client

尽管这会使您的应用容易受到中间人攻击.

Although this will make your app vulnerable to man-in-the-middle attacks.

或者,尝试将证书作为受信任的证书添加到您的 Java 存储中.这个网站可能会有所帮助.http://blog.icodejava.com/tag/get-public-key-of-ssl-certificate-in-java/

Or, try adding the cert to your java store as a trusted cert. This site may be helpful. http://blog.icodejava.com/tag/get-public-key-of-ssl-certificate-in-java/

这是另一个主题,展示了如何将证书添加到您的商店.Java SSL 连接,以编程方式将服务器证书添加到密钥库

Here's another thread showing how to add a cert to your store. Java SSL connect, add server cert to keystore programmatically

关键是:

KeyStore.Entry newEntry = new KeyStore.TrustedCertificateEntry(someCert);
ks.setEntry("someAlias", newEntry, null);