Hello @Jerry Bonetti ,
Thanks for your question.
Because your purpose is testing, I recommend these following steps:
Wrap everything in #if DEBUG so you never ship insecure code to production.
Step 1: Create a Custom WebViewClient (just for Android)
Create a new file called CustomWebViewClient.cs (anywhere in your project):
#if ANDROID
using Android.Webkit;
public class CustomWebViewClient : WebViewClient
{
public override void OnReceivedSslError(global::Android.Webkit.WebView view, SslErrorHandler handler, SslError error)
{
Debug.WriteLine("=== SSL Error bypassed for testing ===");
handler.Proceed();
}
}
#endif
Step 2: Open MauiProgram.cs and add this right after builder.Services... (inside the CreateMauiApp method):
#if ANDROID
Microsoft.Maui.Handlers.WebViewHandler.Mapper.AppendToMapping("MyInsecureCustomization", (handler, view) =>
{
if (view is HybridWebView)
{
handler.PlatformView.SetWebViewClient(new CustomWebViewClient());
}
});
#endif
Step 3: For iOS, add this to your Platforms/iOS/Info.plist (inside the <dict> section):
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Step 4: Test it
- Clean and rebuild your solution
- Set your HybridWebView source like this:
hybridWebView.Source = new UrlWebViewSource
{
Url = "https://10.0.2.2:5001/index.html" // ← change port as needed
};
- Run on Android Emulator.
Check the Output window (Debug tab) — you should see the message "=== SSL Error bypassed for testing ===" if the override worked.
Note: make sure your local web server is running and reachable from the emulator.
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.