2014-05-21 3 views
0

HTTPS 트래픽에 대한 내 도구의 모든 시작에 인증서 표시를 생성 제거해야합니다 :내가 피들러 내가 피들러 코어를 시도하는이 테스트 도구가

이 테스트 도구가 작동
static void Main(string[] args) 
    { 
     #region AttachEventListeners 
     // 
     // It is important to understand that FiddlerCore calls event handlers on the 
     // session-handling thread. If you need to properly synchronize to the UI-thread 
     // (say, because you're adding the sessions to a list view) you must call .Invoke 
     // on a delegate on the window handle. 
     // 

     // Simply echo notifications to the console. Because Fiddler.CONFIG.QuietMode=true 
     // by default, we must handle notifying the user ourselves. 
     Fiddler.FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA) 
     { 
      Console.WriteLine("** NotifyUser: " + oNEA.NotifyString); 
     }; 
     Fiddler.FiddlerApplication.Log.OnLogString += delegate(object sender, LogEventArgs oLEA) 
     { 
      Console.WriteLine("** LogString: " + oLEA.LogString); 
     }; 

     Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS) 
     { 
      Console.WriteLine("Before request for:\t" + oS.fullUrl); 
      // In order to enable response tampering, buffering mode must 
      // be enabled; this allows FiddlerCore to permit modification of 
      // the response in the BeforeResponse handler rather than streaming 
      // the response to the client as the response comes in. 
      oS.bBufferResponse = false; 
     }; 

     Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) 
     { 
      Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl); 

      // Uncomment the following two statements to decompress/unchunk the 
      // HTTP response and subsequently modify any HTTP responses to replace 
      // instances of the word "Microsoft" with "Bayden" 
      //oS.utilDecodeResponse(); oS.utilReplaceInResponse("Microsoft", "Bayden"); 
     }; 

     Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS) 
     { 
      Console.WriteLine("Finished session:\t" + oS.fullUrl); 
     }; 

     // Tell the system console to handle CTRL+C by calling our method that 
     // gracefully shuts down the FiddlerCore. 
     Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress); 
     #endregion AttachEventListeners 

     Console.WriteLine("Starting FiddlerCore..."); 

     // For the purposes of this demo, we'll forbid connections to HTTPS 
     // sites that use invalid certificates 
     Fiddler.CONFIG.IgnoreServerCertErrors = true; 
     Fiddler.CONFIG.bMITM_HTTPS = true; 

     Fiddler.CertMaker.removeFiddlerGeneratedCerts(); 
     if (!Fiddler.CertMaker.rootCertExists()) 
     { 
      if (!Fiddler.CertMaker.createRootCert()) 
      { 
       throw new Exception("Unable to create cert for FiddlerCore."); 
      } 
     } 

     if (!Fiddler.CertMaker.rootCertIsTrusted()) 
     { 
      if (!Fiddler.CertMaker.trustRootCert()) 
      { 
       throw new Exception("Unable to install FiddlerCore's cert."); 
      } 
     } 

     // Because we've chosen to decrypt HTTPS traffic, makecert.exe must 
     // be present in the Application folder. 
     Fiddler.FiddlerApplication.Startup(8877, true, true); 
     Console.WriteLine("Hit CTRL+C to end session."); 

     // Wait Forever for the user to hit CTRL+C. 
     // BUG BUG: Doesn't properly handle shutdown of Windows, etc. 
     Object forever = new Object(); 
     lock (forever) 
     { 
      System.Threading.Monitor.Wait(forever); 
     } 
    } 

    /// <summary> 
    /// When the user hits CTRL+C, this event fires. We use this to shut down and unregister our FiddlerCore. 
    /// </summary> 
    /// <param name="sender"></param> 
    /// <param name="e"></param> 
    static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e) 
    { 
     Console.WriteLine("Shutting down..."); 
     Fiddler.FiddlerApplication.Shutdown(); 
     System.Threading.Thread.Sleep(750); 

    } 

, 나는, HTTPS 트래픽을 캡처 할 수있는 I 내 실제 도구가 필요합니다. 그러나 도구를 시작할 때마다 인증서를 다시 설치하고 다시 신뢰해야합니다. 내가

 Fiddler.CertMaker.removeFiddlerGeneratedCerts(); 

때마다 호출하지 않는 경우,이 도구는 HTTPS 트래픽을 캡처하지 않습니다, 나는 작업 중지를 모니터링하고있어 응용 프로그램은 분명히 요청 피들러에 의해 차단하지만 응용 프로그램에 전달하지 얻을 것 때문에 .

매번 피들러 인증서를 삭제할 필요가 없도록 어떻게 설정해야합니까?

+0

Fiddler 'CertMaker.dll'부가 기능을 사용하고 있습니까? 그렇다면 콘솔에 참조가 표시됩니다. – EricLaw

+0

예, 있습니다. 내가 작성한 것처럼 원칙적으로 모든 것이 작동하며 처음으로 도구를 시작할 때 HTTPS 트래픽이 잘 보입니다. 그것은 도구가 시작될 때마다 피들러 인증서를 제거해야하거나 작동을 멈추는 것입니다. http://i.imgur.com/qv3sif3.png – Hackworth

+0

FWIW, 나는 동일한 문제가 있었고 솔루션은 프로젝트에서 certmaker.dll을 제거하고 대신 makecert.exe를 앱의 출력 폴더에 저장하는 것이 었습니다. 이를 통해 FiddlerCore는 앱 출시 전반에 걸쳐 작동하는 스티커 인증서를 만들 수 있으며 인증서를 한 번만 등록 할 수 있습니다 (SSL 설치/제거 옵션을 쉽게 추가 할 수 있습니다). –

답변

1

응용 프로그램 폴더에 CertMaker.dll이 있습니다. 즉, 응용 프로그램이 시작될 때마다 새 루트 인증서와 새 EE 인증서가 다시 생성됩니다.

는이를 방지하기 위해, 당신은 환경 설정 fiddler.certmaker.bc.keyfiddler.certmaker.bc.cert

또는 CertMaker.dll 제거의 값을 캐시하고 기본 Makecert.exe를 인증서 논리가 적용 할 수 있도록해야합니다.

+0

"fiddler.certmaker.bc.key' 등의 환경 설정 값을 캐시해야합니까? 어떤 기본 설정과 키가 여기에 대해 이야기하고 있습니까? –

+0

명명 된 값은 환경 설정이며 피들러 환경 설정 시스템에 저장됩니다 (책에 포함되어 있습니다 :-). 여기서 문제는 FiddlerCore 기반 응용 프로그램이 Fiddler처럼 레지스트리에 대한 환경 설정을 자동으로 유지하지 않으므로 CertMaker 이후에 레지스트리, 디스크 등의 지정된 환경 설정 값을 명시 적으로 저장해야한다는 것입니다. 루트를 생성 한 다음 응용 프로그램이 다음에 실행될 때 해당 값을 기본 설정 시스템으로 다시로드합니다. – EricLaw

+0

Hmmm ... 좋습니다.하지만 출하 된 어셈블리 대신 MakeCert.exe를 사용하면 수동으로 키를 관리하지 않고도 지속 된 동작을 얻을 수 있습니다. 적어도 그것이 내가보고있는 것이고 Mono를 실행하거나 MakeCert 인증서가 지원되지 않는 특별한 경우를 요구하지 않는 한 가장 쉬운 해결책 인 것 같습니다. –