Mobile api calls require https. The mobile o/s are more security conscious than laptops. Also on a mobile o/s, code can not override certificate validation. You must use a trusted certificate. If using self signed, it must be installed as trusted on the device.
Android Emulator is not able to load URL
Hi Team,
I’m currently using the Android Emulator within Visual Studio 2022 and facing consistent issues accessing the application's APIs. The emulator is unable to reach the endpoints, and when I attempt to load the URLs through the mobile browser inside the emulator, I receive a "Connection is not private" message, and the pages fail to load entirely.
Interestingly, the same API links are working perfectly fine from the browser on same laptop, which rules out any connectivity issues on the host machine.
I've attached a screenshot for reference. Could you please advise.
Developer technologies | .NET | .NET MAUI
2 answers
Sort by: Most helpful
-
Bruce (SqlWork.com) 79,101 Reputation points Volunteer Moderator
2025-08-05T17:09:24.26+00:00 -
Tony Dinh (WICLOUD CORPORATION) 725 Reputation points Microsoft External Staff
2025-08-06T03:58:07.6233333+00:00 Hi Swapnil Desale!
This issue is common for many applications that try to access HTTPS which requires certificate validation.
What is Certificate Validation?
- Every HTTPS server presents an SSL/TLS certificate to prove its identity
- The browser verifies this certificate is legitimate and trustworthy
- This prevents attackers from impersonating websites (man-in-the-middle attacks)
Here's how you can fix this issue:
Install Your SSL Certificate in the Emulator
- Export the SSL certificate (usually
.crt
or.pem
file) from your dev server.- For Android, the certificate must be in PEM or DER format
- If you have a
.p12
or.pfx
file, convert it first
- Drag and drop the certificate file onto the running emulator window
Alternatively, use
adb push yourcert.crt /sdcard/Download/
to push it with adb - Open Settings > Security > Encryption & credentials > Install from SD card (on the emulator) (Note: Path may vary by Android version - look for "Install certificates" or similar)
- Choose the certificate and install it as a "trusted credential".
- Select "VPN and apps" or "CA certificate" when prompted
- Note: User-installed certificates may not work with all apps
- Restart the emulator.
- Navigate back to Chrome and refresh the page (clear cache if needed).
This will ensure Chrome in the emulator trusts the certificate.
Chrome Development Option:
- For local development only, you can navigate to
chrome://flags/#allow-insecure-localhost
- Enable "Allow invalid certificates for resources loaded from localhost"
(Alternative but not recommended) If security is not a concern for your dev APIs, you can temporarily use HTTP (not HTTPS)
Please note that: Android 9+ blocks HTTP by default. You must allow cleartext traffic in your app's
network_security_config.xml
. See hereDocumentation:
- https://developer.android.com/privacy-and-security/security-config
- https://docs.mitmproxy.org/stable/howto-install-system-trusted-ca-android/
I hope this helps!