报错内容
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
解决办法
1NG做跳转处理,先将https请求改为向ng发送http请求,ng做跳板发送https请求
server {
listen 80;
server_name _;
return 301 https://$host$request_uri;
}
解决办法2
服务端配置跳过ssl认证
HttpPost post = new HttpPost(url);
//创建CloseableHttpClient对象-忽略SSL证书
CloseableHttpClient client = null;
try {
SSLConnectionSocketFactory scsf = new SSLConnectionSocketFactory(
SSLContexts.custom().loadTrustMaterial(null, new TrustSelfSignedStrategy()).build(),
NoopHostnameVerifier.INSTANCE);
client = HttpClients.custom().setSSLSocketFactory(scsf).build();
} catch (KeyManagementException e) {
logger.error("调用接口失败:",e);
} catch (NoSuchAlgorithmException e) {
logger.error("调用接口失败:",e);
} catch (KeyStoreException e) {
logger.error("调用接口失败:",e);
}
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(connectTimeout)
.setSocketTimeout(socketTimeout)
.build();
post.setConfig(requestConfig);
ByteArrayEntity entity = new ByteArrayEntity(data.getBytes(StandardCharsets.UTF_8));
entity.setContentType("application/json");
post.setEntity(entity);
CloseableHttpResponse res = client.execute(post);