Fiddlercore - 请求的资源URL是通用的(OSCP相关的)而不是实际的资源

时间:2016-04-26 17:19:41

标签: c# selenium-webdriver fiddlercore

我正在关注this blogpost,试着看看Fiddlercore的作用。 根据博客,生成的控制台输出应该类似于:

Requested resource from URL http://www.mozilla.org/
Requested resource from URL http://mozorg.cdn.mozilla.net/media/css/tabzilla-min.css?build=c2a3f7a
Requested resource from URL http://mozorg.cdn.mozilla.net/media/js/site-min.js?build=c2a3f7a
Requested resource from URL http://mozorg.cdn.mozilla.net/media/css/responsive-min.css?build=c2a3f7a
Requested resource from URL http://mozorg.cdn.mozilla.net/media/img/favicon.ico
Requested resource from URL http://www.mozilla.org/en-US/

但是,在我的情况下,输出有一些相当通用的URL。我想我的代理,浏览器......设置在哪里出错了?但我不知道是什么。 我正在尝试编写等待加载特定资源的代码,因此下面的输出实际上没用。

Starting Fiddler proxy
Fiddler proxy listening on port 6143
Requested resource from URL http://ocsp.digicert.com/
Requested resource from URL http://ocsp.digicert.com/
Requested resource from URL http://ocsp.digicert.com/
Requested resource from URL http://www.mozilla.org/
Requested resource from URL http://ocsp.digicert.com/
Requested resource from URL http://vassg142.ocsp.omniroot.com/
Requested resource from URL http://ocsp.digicert.com/
Requested resource from URL http://clients1.google.com/ocsp
Requested resource from URL http://ocsp.digicert.com/
Requested resource from URL http://clients1.google.com/ocsp
Requested resource from URL http://clients1.google.com/ocsp
Requested resource from URL http://clients1.google.com/ocsp

2 个答案:

答案 0 :(得分:2)

遇到了同样的问题,但通过切换到ChromeDriver并指定ssl选项解决了问题:

    server = new Server(@"C:\Users\<user>\Desktop\browsermob-proxy-2.1.4\bin\browsermob-proxy.
    server.Start();
    client = server.CreateProxy();
    client.NewHar("Test");
    var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy, SslProxy= client.SeleniumProxy };
    ChromeOptions co = new ChromeOptions();
    co.Proxy = seleniumProxy;
    co.AcceptInsecureCertificates = true;
    driver = new ChromeDriver(co);
    ...

答案 1 :(得分:0)

问题已解决。 首先,我没有安装证书,但已修复此代码:

        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.");
            }
        }

其次,我必须为Selenium定义SslProxy以捕获HTTPS:

        OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
        proxy.HttpProxy = string.Format("127.0.0.1:{0}", proxyPort);
        proxy.SslProxy = string.Format("127.0.0.1:{0}", proxyPort);