【发布时间】:2020-08-07 18:01:51
【问题描述】:
我将不得不在不发送证书的情况下使用 https 休息服务,但我的应用程序仍在尝试查找路径。
try
{
HttpsURLConnection connection = (HttpsURLConnection) new URL(null, ResourceUtil.getEnvironmentMessage(URL), new sun.net.www.protocol.https.Handler()).openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.connect();
String inputRequest = buildJsonRequest(request);
connection.setDoOutput(true);
OutputStream ucdlRequestStream = connection.getOutputStream();
requestStream.write(inputRequest.getBytes());
requestStream.flush();
if (connection.getResponseCode() != 200)
{
throw new SystemException("Failed : HTTP error code : " + connection.getResponseCode());
}
BufferedReader responseReader = new BufferedReader(new InputStreamReader((connection.getInputStream())));
String output;
LOGGER.info("Output from Server .... \n");
while ((output = responseReader.readLine()) != null)
{
boolean hasActiveProducts = output.contains("ACTIVE");
LOGGER.info(output);
}
connection.disconnect();
}
catch (IOException | EASystemException e)
{
LOGGER.error(e.getMessage(), e);
throw new SystemException(e.getMessage(), e);
}
LOGGER.info(String.valueOf(hasActiveProducts));
return hasActiveProducts;
看到以下错误: 原因:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径 在 sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
【问题讨论】:
标签: https rest-client