C#:設置CefSharp的一些參數,比如忽略安全證書


 

 

------------吾亦無他,唯手熟爾,謙卑若愚,好學若飢-------------

 

 

 

本次記錄如何設置CefSharp忽略安全證書,以及他的一些其他配置

參考網址

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

這個網站記錄了CefSharp所有可以設置的配置

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

這個網站記錄了如何具體設置,不過第二個網站在剛才測試中好像沒能打開,我簡單說一下

 

 

具體設置

我在第一個參考網站中找到證書,他有倆個,我不知道哪個起作用,我就都配置了

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

這是flash的配置

 

            //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);
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM