I'm building a .NET Maui app using VS2022. I'm testing it using the Android emulator. The app gets its data from an API that is running on my local machine. The API is called from C# code but also from JavaScript in a WebView component. I've been struggling for days with a certificate error. As a first step, I want to at least be able to call the API using the browser without certificate errors (see image below). I've tried generating a certificate and installing it on the emulator. I've also tried using the Mitm proxy. Nothing works :(
2
-
You you chaged network security config of your app to trust user installed certificates? Otherwise the user installed cert is ignored. developer.android.com/privacy-and-security/… Also make sure the certificate contains the IP 10.0.2.2 as Subject Alternative Name extension (DNS).Robert– Robert2025-03-02 14:00:48 +00:00Commented Mar 2 at 14:00
-
Did you try to access the api from the browser in the android emulator? And did you install the certificate in your app?Liyun Zhang - MSFT– Liyun Zhang - MSFT2025-03-07 09:47:30 +00:00Commented Mar 7 at 9:47
Add a comment
|
1 Answer
the certificate must be installed on the webserver that is serving the API. And reach the server via 443 port, not 7011.
2 Comments
Mark Evans
Thanks Raffaele. Have you personally ever got this working? I mean viewed an api running on your local machine from the emulator browser with no certificate error? I've tried several ways to install a certificate on my local machine. I have also tried to import them into the emulator but had a lot of trouble. I couldn't install a CA certificate. I have changed to port 443. But I'm still getting the same error. If you have personally actually managed to get this working, can you please share detailed steps?
Raffaele Bertani
Yes, for production release you must have a valid certificate on your server. But for development porpouses you can add the specific manifest permission to allow clear http communication. What is not clear to me is, do you want a valid https connection even on localhost api or to just make it work even without certificate while developing?
