2

If a user has installed a pfx user certificate on an Android device, chrome browser sees and asks permission to use users client certificate to access a server that accepts such certificates. What is the Xamarin forms equivalent ?

certificate access / selection

How can we access these certificates in Xamarin form apps for Android.

Under windows (UWP) Accessing user certificates is just

              httpClientHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
              httpClientHandler.UseDefaultCredentials = true;

Under Android we are trying to use Custom version AndroidClienthandler

 MyAndroidClientHandler clientHandler = new MyAndroidClientHandler();

In a Custom AndroidClientHandler There are 2 problems to solve
1) how to get a certificate from the users certificates from the keychain ?
Something like this post perhaps? Client Certificates on Android

2) How do you add that cert to the ClientHandler? Can I simply do this
clientHandler.TrustedCerts.Add(cert);
or more likely
Add certificate to SSL Context

Has anyone ever managed to do a HTTPS call using an already installed client certificate from Xamarin forms ?

phil soady
  • 11,043
  • 5
  • 50
  • 95

1 Answers1

3

Looks like Android didn't provide a direct way to use a default credential, but Android provide developers with some choice to use system-wide credentials or app's private credential.

KeyChain may help to launch a system dialog for user to choose a certificate/enter the password. Refering to earlier post.

And extend AndroidClientHandler as posted here is what I found to use the client certificate.

Hope it helps.

Lia
  • 523
  • 2
  • 9
  • Thx Nicole Ill take a look at the links to see if I can figure something out from them. Its mainly Android docu and JAVA blog post. I was hoping someone has managed to the equivalent in Xamarin forms. It is of course in the right direction. – phil soady Mar 06 '20 at 01:45
  • ok not really the solution i was hoping for, but its closer than no tip at all. Thanks Nicole. – phil soady Mar 20 '20 at 14:26