Performing SSL Client Certificate Http Requests with HttpClient

mrskensingtonmrskensington USMember, Beta ✭✭
edited October 2014 in Cross Platform with Xamarin

Hi,

I'm trying to perform a HttpRequest to a server that is configured to only allow requests from clients with the correct Client Certificate. The server is fully configured and is using a CA-Signed SSL Certificate and works fine if I use Firefox with the client certificate installed.

In a test application I've managed to get this working with HttpWebRequest by doing the following...

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
var path = NSBundle.MainBundle.BundleUrl.Path + "/Data/client.p12";
X509Certificate cert = new X509Certificate2(path, "password");
request.ClientCertificates.Add (cert);

var response = await request.GetResponseAsync ();

However I now want to merge this into our existing application which uses HttpClient. From what I've read so far I have to use System.Net.Http.WebRequestHandler and then pass that into the HttpClient constructor, however that class doesn't seem to exist. I'm guessing it's some sort of PCL (I'm using Profile78) Issue or a lack of support in Mono Issue.

Is there any other way of specifying the Client Certificates to use with HttpClient? Is there any way I can use WebRequestHandler in my library?

Thanks in advance!

Answers

Sign In or Register to comment.