Using DotNetBrowser DialogHandler API you can handle the situation when Select SSL Certificate dialog should be displayed. By default, DotNetBrowser displays its own implementation of the dialog where the user can select required certificate in the list of available certificates. In order to override the default behavior, you must register your own implementation of the DialogHandlerinterface with overridden DialogHandler.OnSelectCertificate(CertificatesDialogParams parameters)method. In your implementation, you can display your own dialog or suppress the dialog and select required certificate programmatically.


The following sample demonstrates how to override default implementation with custom Select SSL Certificate dialog:


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


namespace CertificateSelectSample
{
    /// <summary>
    /// Demonstrates how to handle SSL certificate selection.
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            Browser browser = BrowserFactory.Create();
            browser.LoadHandler = new SampleLoadHandler();
            browser.LoadURL("<URL that causes Select SSL Certificate dialog>");

        }

        private class SampleLoadHandler : DefaultLoadHandler
        {
            public override bool OnSelectCertificate(CertificatesDialogParams parameters)
            {
                String message = "Select a certificate to authenticate yourself to " + parameters.HostPortPair.HostPort;
                List<Certificate> certificates = parameters.Certificates;
                if (!(certificates.Count == 0)) {
                    Object selectedValue = certificates[0];
                    if (selectedValue != null) {
                        parameters.SelectedCertificate = ((Certificate) selectedValue);
                        return true;
                    }
                }
                return false;
            }
        }
    }
}