Search code examples
c#winformsssl-certificategeckofx

How can I check if site has valid SSL using GeckoFx browser?


I'm building a C# .NET winform GekoFx browser and I'm trying to display a lock icon if a webpage is secure (has valid SSL).

I tried using this code, but it shows all sites including Google as 'insecure'.

if(selectedBrowser.SecurityState == GeckoSecurityState.Secure)
            {
                button4.Image = SvgDocument.Open<SvgDocument>("icons/lock-outline.svg").Draw();
            } else if (selectedBrowser.SecurityState == GeckoSecurityState.Insecure)
            {
                button4.Image = SvgDocument.Open<SvgDocument>("icons/unlock-outline.svg").Draw();
            }

How can I successfully check if a webpage is secure or not?


Solution

  • I don't have a perfect solution but in the end, I just went with labeling HTTP sites as insecure and HTTPS sites as secure, hoping that SSL certificate errors would be taken care of by Gecko.