我已成功使用生成密钥库
keytool -genkeypair -alias SomeAlias -keyalg RSA -validity 365 -keystore NAME.keystore -storetype JKS
将它放在tomcat配置目录和更新的server.xml文件中,启用8443端口监听。
所以我可以访问 https://开头本地主机:8443 / MyApp的
但是当我试图发布一些数据时 https://开头本地主机:8443 / MyApp的 至 https://开头本地主机:8443 / MyApp的
sun.security.validator.ValidatorException:PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径
我的POST功能:
public void HttpsPostData(String data, URL url){
try {
String encodedData = URLEncoder.encode("data", "UTF-8") + "=" + URLEncoder.encode(data, "UTF-8");
HttpsURLConnection con = (HttpsURLConnection)url.openConnection();
con.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(con.getOutputStream());
wr.write(encodedData);
wr.flush();
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
{
System.out.println(inputLine);
}
in.close();
} catch (IOException ex) {
Logger.getLogger(Sender.class.getName()).log(Level.SEVERE, null, ex);
}
}
我错过了什么?