I have successfully generated a keystore using
keytool -genkeypair -alias SomeAlias -keyalg RSA -validity 365 -keystore NAME.keystore -storetype JKS
placed it in tomcat config dir and updated server.xml file enabling 8443 port listening.
So i can access https://localhost:8443/MyApp
But when i am trying to POST some data from https://localhost:8443/MyApp to https://localhost:8443/MyApp
sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
my POST function:
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);
}
}
what i am missing?