我正在尝试从我的服务器向另一台服务器发送POST请求。它在http上运行良好,当通过https执行时,它表示内部服务器错误 - 来自服务器的文件意外结束。这是我的HTTPS POST代码。
URL url = new URL("https://.../Action")
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
System.out.println("Connection established");
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
conn.setDoOutput(true);
conn.getOutputStream().write(postDataBytes);
//Error in the following line
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
`
答案 0 :(得分:1)
您应该使用SSLsocket。您应该将证书安装到您的keystone。
答案 1 :(得分:0)
对于HTTPS连接,验证其他服务器的SSL证书非常重要。为此,我使用了Shirish在this link上发布的解决方案。
感谢@Indra Uprade帮助我找到问题。