Ejemplo n.º 1
0
        protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
        {
            Task.Run(() =>
            {
                if (!callback.IsDisposed)
                {
                    using (callback)
                    {
                        // Allow the expired certificate from graalonline
                        if (requestUrl.ToLower().Contains("https://classic.graalonline.com"))
                        {
                            callback.Continue(true);
                        }
                        else if (requestUrl.ToLower().Contains("https://era.graalonline.com"))
                        {
                            callback.Continue(true);
                        }
                        else if (requestUrl.ToLower().Contains("https://zone.graalonline.com"))
                        {
                            callback.Continue(true);
                        }
                        else if (requestUrl.ToLower().Contains("https://olwest.graalonline.com"))
                        {
                            callback.Continue(true);
                        }
                        else
                        {
                            callback.Continue(false);
                        }
                    }
                }
            });

            return(true);
        }
Ejemplo n.º 2
0
 protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser,
                                            CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo,
                                            IRequestCallback callback)
 {
     callback.Continue(true);
     return(true);
 }
Ejemplo n.º 3
0
 protected override bool OnQuotaRequest(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
 {
     using (callback) {
         callback.Continue(true);
     }
     return(true);
 }
Ejemplo n.º 4
0
 bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
 {
     if (this.OwnerWebView.IgnoreCertificateErrors)
     {
         callback.Continue(true);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
        protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
        {
            if (request.Url.Contains("Twitter", StringComparison.Ordinal) || request.Url.EndsWith("png") || request.Url.EndsWith("jpg"))
            {
                callback.Continue(false);
                return(CefReturnValue.Cancel);
            }

            return(CefReturnValue.Continue);
        }
Ejemplo n.º 6
0
            public bool OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
            {
                if (!parent.AllowInsecureCerts)
                {
                    return false;
                }

                callback.Continue(true);
                return true;
            }
Ejemplo n.º 7
0
 protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
 {
     using (callback) {
         if (OwnerWebView.IgnoreCertificateErrors)
         {
             callback.Continue(true);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
        protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
        {
            //NOTE: We also suggest you wrap callback in a using statement or explicitly execute callback.Dispose as callback wraps an unmanaged resource.

            //Example #1
            //Return true and call IRequestCallback.Continue() at a later time to continue or cancel the request.
            //In this instance we'll use a Task, typically you'd invoke a call to the UI Thread and display a Dialog to the user
            //You can cast the IWebBrowser param to ChromiumWebBrowser to easily access
            //control, from there you can invoke onto the UI thread, should be in an async fashion
            Task.Run(() =>
            {
                //NOTE: When executing the callback in an async fashion need to check to see if it's disposed
                if (!callback.IsDisposed)
                {
                    using (callback)
                    {
                        //We'll allow the expired certificate from badssl.com
                        if (requestUrl.ToLower().Contains("https://expired.badssl.com/"))
                        {
                            callback.Continue(true);
                        }
                        else
                        {
                            callback.Continue(false);
                        }
                    }
                }
            });

            return(true);

            //Example #2
            //Execute the callback and return true to immediately allow the invalid certificate
            //callback.Continue(true); //Callback will Dispose it's self once exeucted
            //return true;

            //Example #3
            //Return false for the default behaviour (cancel request immediately)
            //callback.Dispose(); //Dispose of callback
            //return false;
        }
Ejemplo n.º 9
0
            protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
            {
                DialogResult dialogResult = MessageBox.Show($"Zertifikatsfehler (ErrorCode: {(int)errorCode} {errorCode}).\nMöchten Sie trotzdem fortfahren?", "Zertifikatsfehler", MessageBoxButtons.YesNo);
                bool         confirm      = true;

                if (dialogResult == DialogResult.No)
                {
                    confirm = false;
                }
                callback.Continue(confirm);
                return(true);
            }
Ejemplo n.º 10
0
            bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
            {
                if (!callback.IsDisposed)
                {
                    using (callback)
                    {
                        callback.Continue(true);
                        return(true);
                    }
                }

                return(false);
            }
        public CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
        {
            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    callback.Continue(true);
                    return(CefReturnValue.ContinueAsync);
                }
            }

            return(CefReturnValue.Continue);
        }
Ejemplo n.º 12
0
        protected override bool OnCertificateError(IWebBrowser chromiumWebBrowser, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
        {
            Task.Run(() =>
            {
                if (!callback.IsDisposed)
                {
                    using (callback)
                    {
                        callback.Continue(true);
                    }
                }
            });

            return(true);
        }
Ejemplo n.º 13
0
        public CefReturnValue OnBeforeResourceLoad(
            IWebBrowser browserControl,
            IBrowser browser,
            IFrame frame,
            IRequest request,
            IRequestCallback callback)
        {
            if (request.Url.Contains("chrome-devtools://"))
            {
                callback.Dispose();
                return(CefReturnValue.Continue);
            }
            if (!this._canLoad)
            {
                callback.Dispose();
                return(CefReturnValue.Cancel);
            }
            if (this.BlockManager.IsBlock(request.Url))
            {
                this._api.Console.Error((object)("GET " + request.Url + " net::ERR_BLOCKED_BY_ADBLOCKER"));
                callback.Continue(false);
                callback.Dispose();
                return(CefReturnValue.Cancel);
            }
            Uri result;

            if (Uri.TryCreate(request.Url, UriKind.Absolute, out result))
            {
                this._domainLoading.Add(result.Host);
                if (string.IsNullOrEmpty(request.ReferrerUrl) && !request.IsReadOnly && !request.IsDisposed)
                {
                    this._api.Loading.FakeReffer = result.Scheme + "://" + result.Host;
                    request.SetReferrer(this._api.Loading.FakeReffer, ReferrerPolicy.Default);
                    this._api.Loading.IsFakeReffere = true;
                }
            }
            CefReturnValue cefReturnValue = CefReturnValue.Continue;

            if (this._handler != null)
            {
                cefReturnValue = this._handler.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);
            }
            if (!callback.IsDisposed)
            {
                callback.Dispose();
            }
            return(cefReturnValue);
        }
Ejemplo n.º 14
0
        public virtual CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request,
                                                           IRequestCallback callback)
        {
            var context = new ResourceRequestContext
            {
                Method   = request.Method,
                Referrer = !string.IsNullOrEmpty(request.ReferrerUrl) ? new Uri(request.ReferrerUrl) : null,
                Url      = new Uri(request.Url)
            };

            _requestFilter.CanLoadResourceAsync(context)
            .ContinueWith(task =>
            {
                using (callback)
                {
                    if (!task.IsCompleted)
                    {
                        if (task.Exception != null)
                        {
                            foreach (var ex in task.Exception.Flatten().InnerExceptions)
                            {
                                _logger.LogError(LoggerEventIds.ResourceRequestFilterError, ex,
                                                 "Error processing IResourceRequestFilter for url '{0}'", context.Url);
                            }
                        }
                        else
                        {
                            _logger.LogError(LoggerEventIds.ResourceRequestFilterError,
                                             "Error processing IResourceRequestFilter for url '{0}', no exception returned",
                                             context.Url);
                        }

                        callback.Cancel();
                    }
                    else
                    {
                        callback.Continue(task.Result);
                    }
                }
            });

            return(CefReturnValue.ContinueAsync);
        }
        bool IRequestHandler.OnCertificateError(IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback)
        {
            //NOTE: If you do not wish to implement this method returning false is the default behaviour
            // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
            //callback.Dispose();
            //return false;

            //NOTE: When executing the callback in an async fashion need to check to see if it's disposed
            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    //To allow certificate
                    callback.Continue(true);
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 16
0
        protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
        {
            if (!callback.IsDisposed)
            {
                using (callback)
                {
                    var headers = request.Headers;
                    var ha      = headers["Authorization"];
                    if (ha == null)
                    {
                        headers.Add("x-chrome", GlobalVars.HardwareIDStr);
                        request.Headers = headers;
                    }

                    callback.Continue(true);
                    return(CefReturnValue.ContinueAsync);
                }
            }

            return(CefReturnValue.Continue);
        }
Ejemplo n.º 17
0
 //
 // Summary:
 //     Called when JavaScript requests a specific storage quota size via the webkitStorageInfo.requestQuota
 //     function.  For async processing return true and execute CefSharp.IRequestCallback.Continue(System.Boolean)
 //     at a later time to grant or deny the request or CefSharp.IRequestCallback.Cancel()
 //     to cancel.
 //
 // Parameters:
 //   originUrl:
 //     the origin of the page making the request
 //
 //   newSize:
 //     is the requested quota size in bytes
 //
 //   callback:
 //     Callback interface used for asynchronous continuation of url requests.
 //
 // Returns:
 //     Return false to cancel the request immediately. Return true to continue the
 //     request and call CefSharp.IRequestCallback.Continue(System.Boolean) either
 //     in this method or at a later time to grant or deny the request.
 public bool OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
 {
     callback.Continue(true);
     return(true);
 }
Ejemplo n.º 18
0
 bool IRequestHandler.OnQuotaRequest(IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback)
 {
     callback.Continue(true);
     return true;
 }