Forum Xamarin.Android

How to send client certificates in a HTTPS request

MichaelMcCoolMichaelMcCool GBMember ✭✭
edited December 2018 in Xamarin.Android

I am using HttpClient to access a REST service. I now want to access that service using HTTPS and pass a client certificate.

  1. Is it possible using HttpClient, and if so how
  2. If it is not possible can someone post a solution

This problem seems to be a very common problem for developers using Xamarin. It would be a good idea for someone form Xamarin/Microsoft to give a definitive answer on how to do this. It may be useful for someone to write an article explaining how this can be done.


  • jezhjezh Member, Xamarin Team Xamurai
  • MichaelMcCoolMichaelMcCool GBMember ✭✭

    Thanks for that, but I had already seen this. What I would like is some guidance from the Xamarin/Microsoft team on how this is to be done and also why it needs to be done in this way. There is no clear documentation from them. There doesn't seem to be anyway of using HttpClient as the Certificates property is not implemented. There doesn't seem to be anyway of doing it using AndroidClientHandler.

    What the community needs is clear guidance on this. There is a need for it as there a huge number of queries on it on various forums.

  • Did you succeed with this issue?

  • MichaelMcCoolMichaelMcCool GBMember ✭✭


    I did not manage to get this to work, but have a look at this thread

    Also don't use self signed certificates for your web server. I think this was the problem I was having

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    Helo all,
    @MichaelMcCool -> i'm trying since several days to make a call to https but that doesn't work.
    i've generate with openSSL a certificate and added to IIS.
    i've added the certificate into my android device

    but when i call the url in https i receive an SSL error -> certificate verify failed

    I can't find a solution for to make an https call

    Have you got any idea about how to call some url in https with an android device who has a certificate ?


  • MichaelMcCoolMichaelMcCool GBMember ✭✭

    I would use a proper (non-self signed) certificate on SSL. I could never get my app to connect to IIS when using self-signed certificates. They are relatively cheap about , you will easily get that money back as it is one more thing you can discount when trying to get client certificates to work.

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    Hello again @MichaelMcCool for you the problem is due because it's the certificate self sign ? but one question how i can recognize a trust certificate ?

    one of my idea would be perhaps -> take a certificate on the server who is trust and added to the IIS web service and after installed on the device ..

    thanks for your time

  • MichaelMcCoolMichaelMcCool GBMember ✭✭

    It has to be the correct type of certificate (SSL) and unless it is a wildcard or SAN certificate it will be tied to a single domain.

    My advice is to buy one or if your server has access to the internet try LetsEncrypt which can issue free certificates

  • ChristopheBERNARDChristopheBERNARD BEMember ✭✭✭✭✭

    Hello @MichaelMcCool
    thanks for the advice we will try and come again if succes of fail


Sign In or Register to comment.