I'm using Microsoft HTTP Client Libraries from NuGet and I'm basically trying to allow TLS authentication in HttpClient using X509Certificate2 certificates.
I have tried creating the client like this:
WebRequestHandler certHandler = new WebRequestHandler () {
ClientCertificateOptions = ClientCertificateOption.Manual,
UseDefaultCredentials = false
};
certHandler.ClientCertificates.Add (this.ClientCertificate);
HttpClient client = new HttpClient (certHandler);
However certHandler.ClientCertificates
is failing because this getter is not implemented in Mono, so I get a NotImplementedException from that. (I'm not sure why that's still a TODO.)
So far I'm out of luck. Any ideas how can I simply set a client certificate on HttpClient in Mono environment?
It looks as if it's simply a matter of being able to pass the client certificate collection to the HttpWebRequest in CreateWebRequest, so since inheriting won't work, I just copy/pasted the class from mono and added the implementation.
now in your code use a WebRequestHandlerWithClientCertificates instead of a WebRequestHandler