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);
        }
相關文章
相關標籤/搜索