WebView2 IgnoreHttpsError Demo - Ignoring HTTPS Certificate Errors
Overview
Demonstrates how to ignore HTTPS certificate errors in cWebView2Host, useful for accessing internal sites that use self-signed certificates.
Project Structure
Download Source [ Note: Re-register the DLL file in the bin directory ]
Source code is available in the VBMAN2 project's demos/webview2/ignoreHttpsError directory.
ignoreHttpsError/
├── Form1.frm # Main form, containing certificate error bypass configuration
├── vbman2_webview2.vbp # VB6 project file
└── vbman2_webview2.vbw # VB6 workspace fileCore Code Walkthrough
1. Declaration and Initialization (Form1.frm)
Dim WithEvents wv As cWebView2Host
Private Sub Form_Load()
Set wv = New cWebView2Host
wv.Initialize Me.hWnd, "https://cad.vb6.pro/" ' Self-signed certificate site
End SubUses WithEvents to receive the Create event. The target URL is a site using a self-signed certificate.
2. Configure Security Options in Create Event
Private Sub wv_Create()
wv.Security.CertificateErrorAction = CEA_AlwaysAllow
End SubKey: Security options must be set in the wv_Create event, when WebView2 has been created but navigation has not yet truly started.
Feature Description
Certificate Error Bypass
CEA_AlwaysAllowenum value always allows certificate errors- Internally injects
--ignore-certificate-errorsinto browser command-line arguments - Must be set before navigation starts
Three-Phase Initialization Pattern
Initialize(hWnd, url)→ Create WebView2wv_Create()→ Configure security options- Auto-navigate → Page loads normally
Why Not Set in Form_Load
- Initialize starts asynchronous WebView2 environment creation
- Security settings need to take effect after environment creation but before navigation starts
wv_Createis exactly this time window
Technical Notes
CEA_AlwaysAllow Implementation: cWebView2Host injects the
--ignore-certificate-errorsChrome command-line switch intoAdditionalBrowserArguments. This is the most reliable approach, as CDP'sSecurity.setOverrideCertificateErrorsis unreliable in WebView2Timing: Must be set in the
wv_Createevent. If set after this, the current navigation cannot be affectedGlobal Effect: This setting affects all subsequent navigations, not just the initial URL
Security Warning: Use this feature with caution in production environments; only use in trusted networks
Use Cases
- Internal development environments using self-signed certificates
- Test environments with improperly configured certificates
- Enterprise intranets using private CAs
- Debugging HTTPS-related issues
Extension Suggestions
- Use conditional logic to enable certificate bypass only for specific domains
- Production environments should use valid certificates rather than bypassing verification
- Future ICoreWebView2_14 interface may support deeper certificate control