Java 如何解密HttpsURLConnection

Java 如何解密HttpsURLConnection,java,encryption,response,httpsurlconnection,Java,Encryption,Response,Httpsurlconnection,我的代码向网站发出POST请求,但响应看起来像是加密的,带有奇怪的字符。当我将我的应用程序配置为使用fiddler代理时,响应是有效的。如何使我的应用程序解密此响应 public class Login { public Login() throws Exception { URL url = new URL("https://account.leagueoflegends.com/auth"); HttpsURLConnection conn = (HttpsURLConnection)url

我的代码向网站发出POST请求,但响应看起来像是加密的,带有奇怪的字符。当我将我的应用程序配置为使用fiddler代理时,响应是有效的。如何使我的应用程序解密此响应

public class Login {
public Login() throws Exception {
URL url = new URL("https://account.leagueoflegends.com/auth");
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
conn.setDoInput(true);
conn.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36");
conn.addRequestProperty("Cookie", "xxx");
conn.addRequestProperty("Content-Length", "406");
conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
conn.addRequestProperty("Accept-Encoding", "gzip,deflate");
conn.addRequestProperty("Connection", "keep-alive");
conn.addRequestProperty("Referer", "xxx");
conn.setDoOutput(true);

OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());

writer.write("xxx");
writer.flush();
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = reader.readLine()) != null) {
  System.out.println(line);
}
writer.close();
reader.close();

}

您正在明确请求压缩流:

conn.addRequestProperty("Accept-Encoding", "gzip,deflate");

拆下该管路以拆下压缩。压缩与加密不同幸运的是,它不需要您提供密钥。

相关:欢迎使用SO,Krystian。下次Krystian时,不要忘记从流中添加一些示例输入,如果字节无法轻松打印为字符,最好使用十六进制。其他人,因为问题不清楚而关闭?真正地