java程序中访问https时,报 PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcept

Posted 七星6609

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java程序中访问https时,报 PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcept相关的知识,希望对你有一定的参考价值。

在java中使用https访问数据时报异常:

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

需要使用keytool工具,将对应域名的证书导入到jdk的cacerts中,这个证书可以是*.crt,*.cer等证书

cacerts包含了很多CA证书,位置在Java的安装目录: Javajdk1.8.0_181jrelibsecuritycacerts

执行如下命令,可将证书导入到cacerts中,使其成为可信证书:

cd D:IDEJavajdk1.8.0_181jrelibsecurity
keytool -importcert -alias httpfs -keystore cacerts -file D:IDEJavajdk1.8.0_181jrelibsecurityssl.cer

需要输入cacerts证书库密码:changeit

如果没有证书,可以使用Chrome浏览器访问https域名,下载对应的证书,详情请参照:https://blog.csdn.net/qq_31222053/article/details/94174506

 

以上是关于java程序中访问https时,报 PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderExcept的主要内容,如果未能解决你的问题,请参考以下文章

Java访问https时解决sun.security.validator.ValidatorException: PKIX path building failed 问题

Java生成证书工具类 InstallCert.java解决httpClient访问https出错:PKIX path building failed

java PKIX path validation failed 求教大神帮助解决

Java -> Flask Https 请求:javax.net.ssl.SSLHandshakeException:PKIX 路径构建失败

解决 sun.security.validator.ValidatorException: PKIX path building failed

解决PKIX path building failed