使用HttpClients 请求第三方post接口报错,帮忙看一下如何解决,错误日志如下
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: validity check failed
代码 :
```java
HttpPost httpPost = new HttpPost(NanShuoUrlEnum.getUrl(host, NanShuoUrlEnum.GET_TOKEN));
// 请求参数
JSONObject data = new JSONObject();
data.put("userName","apitest");
data.put("userPwd","123456");
data.put("phone","18756005448");
StringEntity entityParams = new StringEntity(data.toString(), "utf-8");
entityParams.setContentEncoding("UTF-8");
httpPost.setHeaders(new BasicHeader[]{
new BasicHeader("Content-Type", "multipart/form-data")
});
httpPost.setEntity(entityParams);
CloseableHttpClient client = HttpClients.createDefault();
CloseableHttpResponse httpResponse = client.execute(httpPost); // 这行代码报错
String json = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
```