sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
原因:中国金融认证中心 颁发的HTTPS证书,不被JDK信赖
那只能把证书注入到JDK中,keytool是JDK自带的
切换到jre的%JAVA_HOME%/jre/lib/security下,切记,一定要在安装java目录的%JAVA_HOME%/jre/lib/security 下,不然没有效果,可以用 which java 查询
keytool -import -alias abc -keystore cacerts -storepass changeit -file C:downpathxxx.cer
然后回车: 输入 “是” 就能导入成功
然后执行程序访问即可
查看证书
keytool -list -keystore cacerts -alias abc
来源 灰信网