我尝试使用https请求本地服务而无需进行证书检查。但我得到了这个答案。SSLHandshakeException:ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:
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
这里是部分代码:
try {
RestTemplate restTemplate = new RestTemplate();
HttpsURLConnection.setDefaultHostnameVerifier(
(hostname, session) -> hostname.equals("IPADDRESS"));
responseEntity = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class);
} catch (HttpClientErrorException e) {
LOGGER.error(e.toString());
}
这里有什么问题?
服务器正在使用自签名或过期证书 –
自签名证书 – emoleumassi