java请求https接口遇到的问题

[2018-12-28 14:10:52.169] [ERROR] [http-nio-8081-exec-8] [org.jasig.cas.client.util.CommonUtils] >>> 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证书

解决方案:需要导入https证书

keytool -import -alias cas-cert -file [cer fllename] -keystore ${JAVA_HOME}/jre/lib/security/cacerts

备注:默认密码是changeit

注意的要点:

1)JAVA_HOME目录必须指向jdk,而不是jre

2)导入证书要保证有权限,如果没权限,可以整个目录复制出来,再重新制定JAVA_HOME的位置

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐