By default DotNetBrowser rejects loading HTTPS web sites with invalid SSL certificates for security reasons. If you need to ignore invalid SSL certificates and continue loading web page, you can register your LoadHandler implementation where you decide whether invalid SSL certificates should be ignored or not. For example:

С#

private class SampleLoadHandler : DefaultLoadHandler
{
    public override bool OnCertificateError(CertificateErrorParams errorParams)
    {
        // Return false to ignore certificate error.
        return false;
    }
}

VB.NET

Private Class SampleLoadHandler
    Inherits DefaultLoadHandler

    Public Overrides Function OnCertificateError(ByVal errorParams As CertificateErrorParams) As Boolean
        'Return false to ignore certificate error.
        Return False
    End Function
End Class


The CertificateErrorParams parameter provides information about invalid SSL certificate. You can decide whether certificate is allowed or not using its details.


Example

С#

using DotNetBrowser;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace CertificateErrorSample
{
    /// <summary>
    /// Demonstrates how to handle SSL certificate errors.
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Browser browser = BrowserFactory.Create();

            browser.LoadHandler = new SampleLoadHandler();

            browser.LoadURL("<https-url-with-invalid-ssl-certificate>");

        }

        private class SampleLoadHandler : DefaultLoadHandler
        {
            public override bool OnCertificateError(CertificateErrorParams errorParams)
            {
                Certificate certificate = errorParams.Certificate;

                Console.WriteLine("ErrorCode = " + errorParams.CertificateError);
                Console.WriteLine("SerialNumber = " + certificate.SerialNumber);
                Console.WriteLine("FingerPrint = " + certificate.FingerPrint);
                Console.WriteLine("CAFingerPrint = " + certificate.CAFingerPrint);

                string subject = certificate.Subject;
                Console.WriteLine("Subject = " + subject);

                string issuer = certificate.Issuer;
                Console.WriteLine("Issuer = " + issuer);

                Console.WriteLine("KeyUsages = " + String.Join(", ", certificate.KeyUsages));
                Console.WriteLine("ExtendedKeyUsages = " + String.Join(", ", certificate.ExtendedKeyUsages));

                Console.WriteLine("HasExpired = " + certificate.HasExpired);

                // Return false to ignore certificate error.
                return false;
            }
        }
    }
}

VB.NET

Imports DotNetBrowser

Module CertificateErrorSample
    Sub Main()
        Dim browser As Browser = BrowserFactory.Create()
        browser.LoadHandler = New SampleLoadHandler()
        browser.LoadURL("<https-url-with-invalid-ssl-certificate>")
    End Sub

    Private Class SampleLoadHandler
        Inherits DefaultLoadHandler

        Public Overrides Function OnCertificateError(ByVal errorParams As CertificateErrorParams) As Boolean
            Dim certificate As Certificate = errorParams.Certificate
            Console.WriteLine("ErrorCode = " & errorParams.CertificateError)
            Console.WriteLine("SerialNumber = " & certificate.SerialNumber)
            Console.WriteLine("FingerPrint = " & certificate.FingerPrint)
            Console.WriteLine("CAFingerPrint = " & certificate.CAFingerPrint)
            Dim subject As String = certificate.Subject
            Console.WriteLine("Subject = " & subject)
            Dim issuer As String = certificate.Issuer
            Console.WriteLine("Issuer = " & issuer)
            Console.WriteLine("KeyUsages = " & String.Join(", ", certificate.KeyUsages))
            Console.WriteLine("ExtendedKeyUsages = " & String.Join(", ", certificate.ExtendedKeyUsages))
            Console.WriteLine("HasExpired = " & certificate.HasExpired)

            'Return false to ignore certificate error.
            Return False
        End Function
    End Class
End Module