C#:设置CefSharp的一些参数,好比忽略安全证书

 

 

------------吾亦无他,惟手熟尔,谦卑若愚,好学若饥-------------

 

 

 

本次记录如何设置CefSharp忽略安全证书,以及他的一些其余配置

参考网址

https://peter.sh/experiments/chromium-command-line-switches/html

这个网站记录了CefSharp全部能够设置的配置api

http://www.codebye.com/cefsharp-help-2-config-manage.html安全

这个网站记录了如何具体设置,不过第二个网站在刚才测试中好像没能打开,我简单说一下app

 

 

具体设置

我在第一个参考网站中找到证书,他有俩个,我不知道哪一个起做用,我就都配置了测试

            //安全证书
            
            settings.CefCommandLineArgs.Add("--ignore-urlfetcher-cert-requests", "1");
            settings.CefCommandLineArgs.Add("--ignore-certificate-errors", "1");

这是flash的配置fetch

 

            //flash
            settings.CefCommandLineArgs.Add("ppapi-flash-path", AppDomain.CurrentDomain.BaseDirectory + "\\Plugins\\pepflash\\pepflashplayer.dll");

 

 

具体放入的位置参考我上篇博客的InitializeCefSharp方法里,我写个Demo网站

 

        /// <summary>
        /// 解决anycpu不能兼容
        /// </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        private static void InitializeCefSharp()
        {
            var settings = new CefSettings();

            // Set BrowserSubProcessPath based on app bitness at runtime
            settings.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                                                   Environment.Is64BitProcess ? "x64" : "x86",
                                                   "CefSharp.BrowserSubprocess.exe");
            //安全证书
            
            settings.CefCommandLineArgs.Add("--ignore-urlfetcher-cert-requests", "1");
            settings.CefCommandLineArgs.Add("--ignore-certificate-errors", "1");
            //settings.CefCommandLineArgs.Add("allow-http-background-page", "1");
            //settings.CefCommandLineArgs.Add("allow-insecure-localhost","1");
            //settings.CefCommandLineArgs.Add("allow-http-screen-", "1");
            
            //settings.CefCommandLineArgs.Add("reduce-security-for-testing", "1");
            
   
            //flash
            settings.CefCommandLineArgs.Add("ppapi-flash-path", AppDomain.CurrentDomain.BaseDirectory + "\\Plugins\\pepflash\\pepflashplayer.dll");

            // Make sure you set performDependencyCheck false
            Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
        }
相关文章
相关标签/搜索