解决jdk ssl PKIX path building failed异常

ssl证书ca比较新或自行颁发的证书,jdk不受信任


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

1、使用浏览器导出证书

JDK 解决证书不受信异常_第1张图片

2、导入jdk

cd $JAVA_HOME/jre/lib/security
cp cacerts cacerts.bak
keytool -import -alias dangdang.com -keystore cacerts -file /tmp/dangdang.cer
输入密码,keystore默认密码是changeit

3、重启服务生效

重启后会应用导入后的keystore