javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Usage constraint TLSServer check failed: SHA1 used with certificate: CN=证明书名字XXX, O="XXXXX.", C=XXXXX. Usage was tls server
原因:证明书过期
解决方案1
找到要访问的URL通过浏览器,获取证明书。
把证明书导入到jre里面
C:\Program Files\Java\jdk1.8.0_171\bin
keytool -import -alias 证明书别名 -file C:\Users\Desktop\证明书名字XXX.cer -keystore "C:\Program Files\Java\jdk1.8.0_171\jre\lib\security\cacerts" -storepass changeit
keytool -import -alias 证明书别名 -file C:\Users\Desktop\证明书名字XXX.cer -keystore "C:\Program Files\Java\jre1.8.0_171\lib\security\cacerts" -storepass changeit
删除证明书
C:\Program Files\Java\jre1.8.0_171\bin
keytool -delete -alias 证明书别名 -keystore "C:\Program Files\Java\jre1.8.0_171\lib\security\cacerts" -storepass changeit
keytool -delete -alias 证明书别名 -keystore "C:\Program Files\Java\jdk1.8.0_171\jre\lib\security\cacerts" -storepass changeit