Self-Signed Certificate skip validation (toggleable)

I am using @ionic/angular and want to create an Android and iOS app from my Angular SPA with Capacitor. My backend in the local network has a self-signed certificate (mandatory). In the browser, this is not a problem; the page can be accepted as trustworthy once. However, in my apps, this doesn’t seem to work based on my research.

When I open my Android emulator in Android Studio and make an HTTPS request to the endpoint with the self-signed certificate, I get the following error in the Android Studio Logcat: “handshake failed; returned -1, ssl error code 1, net_error -202”.

Is there a suitable approach to disable the verification on Android and iOS for production? I have already read about a plugin (GitHub - jcesarmobile/ssl-skip) that is supposed to skip the verification, but I’m unsure if this is a viable solution, especially since the app will later be made available on the Android and iOS stores. Additionally, my applications should later have access outside the LAN, so the verification must be active again (must be toggleable).

Since I am still quite new to this environment, I would appreciate an idea for a solution approach.

Thank you.

That plugin can’t be used in production, at least not if you plan to publish to Google Play or App Store

This plugin is only meant to be used during development, publishing an app with this plugin installed can lead to app rejections on Google Play Store and App Store. Before submitting your app remember to uninstall the plugin and run sync command again.

And doesn’t support changing the behaviour programmatically, but even if it allowed to disable the behavior, Google play will still not allow to publish the app with that code as it’s scanned and will not allow it.