首页 > 编程语言 > 详细

java程序中访问https时,报 PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

时间:2019-11-18 17:33:15      阅读:460      评论:0      收藏:0      [点我收藏+]

在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的安装目录: Java\jdk1.8.0_181\jre\lib\security\cacerts

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

cd D:\IDE\Java\jdk1.8.0_181\jre\lib\security
keytool -importcert -alias httpfs -keystore cacerts -file D:\IDE\Java\jdk1.8.0_181\jre\lib\security\ssl.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

原文:https://www.cnblogs.com/qixing/p/11883494.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!