how to Capture https with fiddler, in java

前端 未结 4 2027
春和景丽
春和景丽 2020-11-28 01:58

I am running the following java program in the Eclipse IDE:

import java.net.*;
import java.io.*;

public class HH
{
    public static void main(String[] arg         


        
4条回答
  •  半阙折子戏
    2020-11-28 02:17

    Create a keystore containing the fiddler certificate and use it:

    java -DproxySet=true -DproxyHost=127.0.0.1 -DproxyPort=8888 -Dhttps.proxyPort=8888 -Dhttps.proxyHost=127.0.0.1 -Djavax.net.ssl.trustStore= -Djavax.net.ssl.trustStorePassword= -jar test.jar
    

    If you use third party HTTP libraries, you need to set the connection proxies. Example with Apache Commons HttpClient:

    HttpClient httpClient = new HttpClient();
    httpClient.getHostConfiguration().setProxy("localhost", 8888);
    

    UPDATE:

    if you are using Apache HttpClient 4.5.5 or newer, you need to do it like this:

    HttpHost proxy = new HttpHost("localhost", 8888, "http");
    DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
    CloseableHttpClient httpclient = HttpClients.custom()
                    .setRoutePlanner(routePlanner)
                    .build();
    

提交回复
热议问题