如何使用 Fiddler2 或类似工具捕获进出 Java Web 应用程序的 HTTP(S) 流量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6167006/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 14:38:17  来源:igfitidea点击:

How to capture HTTP(S) traffic from and to a Java web application with Fiddler2 or similar tool?

javacapturefiddler

提问by Infeligo

I want to capture data that my web application sends and receives from a CAS server via HTTPS. I tried using Fiddler2, but couldn't make it capture traffic from Java web application. It seems I need to configure it to use Fiddler2 as a proxy. How do I do it correctly?

我想捕获我的 Web 应用程序通过 HTTPS 从 CAS 服务器发送和接收的数据。我尝试使用 Fiddler2,但无法使其捕获来自 Java Web 应用程序的流量。看来我需要将其配置为使用 Fiddler2 作为代理。我该怎么做才能正确?

Some additional info. I have already imported Fiddler's certificate with keytool. Running web application on Tomcat 7. Using IntelliJ Idea.

一些额外的信息。我已经用 keytool 导入了 Fiddler 的证书。在 Tomcat 7 上运行 Web 应用程序。使用 IntelliJ Idea。

回答by Piskvor left the building

Run the JVM with these parameters:

使用以下参数运行 JVM:

-Dhttps.proxyHost=yourhostwithfiddler -Dhttps.proxyPort=8888

Alternately, you could set the Java default proxy through a GUI - see http://www.java.com/en/download/help/proxy_setup.xml

或者,您可以通过 GUI 设置 Java 默认代理 - 请参阅http://www.java.com/en/download/help/proxy_setup.xml

回答by Tarlog

In addition to Piskvor answer, make sure you configure Fiddler to capture the HTTPS traffic: Tools --> Fiddler Options --> HTTPS --> Capture HTTPS CONNECTs

除了 Piskvor 答案,请确保您配置 Fiddler 以捕获 HTTPS 流量:工具 --> Fiddler 选项 --> HTTPS --> 捕获 HTTPS CONNECTs

回答by Jean Lestang

You can also use directly the settings screen: "File / Settings...", then choose"IDE Settings / HTTP Proxy". Then tick "Use proxy", "Host name": localhost, "Port number": 8888

您也可以直接使用设置屏幕:“文件/设置...”,然后选择“IDE 设置/HTTP 代理”。然后勾选“使用代理”,“主机名”:localhost,“端口号”:8888