0

I have a Xamarin project, and a .net core web API project. How can I connect the Xamarin (especially the android project), to Localhost using https (not http)?

What I have tried: I have found some examples online of setting up an HttpClient with a custom HttpClientHandler, where HttpClientHandler has a clientcertificate assigned. But.. When I do this I am unsure of how to get the certificate that is generated when I launch the https .netcore web api project in localhost. For instance the Microsoft documentation suggests this command, but that wants to create a new cert, not use the one generated and running:

dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p <cryptic-password>

Another thought I had was to save https for production/hosted environment as most examples are to force the setup to use http (changes to manifest file, and the 10.0.2.2 localhost loopback), but for whatever reason this always results in 'bad request' for me on Pie (android 9.x).

What should I research next to get this to work, or has anyone had success with this?

Thank you!

Chris
  • 968
  • 16
  • 27
  • there are two different parts to this - 1. is setting up your local IIS to use SSL, and 2. is getting your mobile clients to trust a self-signed cert. Which part are you having problems doing? – Jason Oct 26 '19 at 18:22
  • @Jason you are right, I asked this question all sorts of scatterbrained. My IISExpress for vs2019 is running a .netcore web api, and I can get to the http and the https both in the browser for the api method that I need from my pc using chrome no problem. WHen I use the android simulator for visual studio, in https it doesn't like my certificate and in http it claims bad request. – Chris Oct 26 '19 at 18:30

0 Answers0