问题描述
使用 RestTemplate 调用远程接口,报错:PKIX path building failed , 具体错误信息如下所示:
I/O error on POST request for "https://abc.cn/auth/token":
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target;
nested exception is 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,
stackTrace:
[org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:696),
org.springframework.web.client.RestTemplate.execute(RestTemplate.java:644),
问题分析
JVM自身维护了一个默认的信任证书,一个没有后缀名的文件cacerts,位于java安装目录下(%JAVA_HOME%/jre/lib/security/cacerts)。
Java在访问不