【问题标题】:How to decrypt HttpsURLConnection如何解密 HttpsURLConnection
【发布时间】:2015-01-16 16:16:05
【问题描述】:

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

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();

}

【问题讨论】:

  • 欢迎来到 SO,克里斯蒂安。下次 Krystian 时不要忘记从流中添加一些示例输入,如果字节不能轻松地打印为字符,最好使用十六进制。其他人,因为问题不清楚而关闭?真的吗?

标签: java encryption response httpsurlconnection


【解决方案1】:

您明确请求压缩流:

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

删除该行以删除压缩。幸运的是,压缩与加密不同,它不需要您提供密钥。

【讨论】:

猜你喜欢
  • 2013-05-27
  • 2015-07-18
  • 1970-01-01
  • 1970-01-01
  • 2016-03-28
  • 1970-01-01
  • 2016-07-28
  • 1970-01-01
  • 2015-01-22
相关资源
最近更新 更多