当前位置:首页 > 编程语言 > 正文

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

11-19 编程语言

标签:get   java程序   art   chrome浏览器   hbuilder   tps   cert   building   ble   

在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.SunCertPathBuilderException: unable to find valid certification path to requested target

标签:get   java程序   art   chrome浏览器   hbuilder   tps   cert   building   ble   

温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/file/biancheng/12248.html