I'm developing my first Xamarin.Forms App and have a backend API built using ASP.Net Core. I want all calls to the API to be via HTTPS so followed this guide for setting up HTTPS for development in ASP.NET Core. This, I believe, will let me use the IIS Express Development Certificate from within Visual Studio.
Up to this point I had been making all calls to the API from my Xamarin.Forms Android App via the emulator using HttpClient and the following http uri
http://10.0.2.2:44321/api/User
but now with SSL enabled for my API I need to make the call from the app using the following uri
https://10.0.2.2:44321/api/User
However, simply changing http to https gives the following error
{Javax.Net.Ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. ---> Java.Security.Cert.CertificateException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. ---> Java.Security.Cert.CertPathValidatorException: Trust anchor for certification path not found.
--- End of inner exception stack trace ---
I presume this is because the the Xamarin.Forms App does not list the IIS Development Certifcate as being trusted, i.e., with Swagger (Swashbuckle) running from my API I can hit the endpoint with no problems; with postman running with SSL certificate verification turned off I can also hit the endpoint.
How can I setup a Xamarin.Forms App (specifically Android) to trust the IIS Development Certificate for development purposes?