I'm writing a UWP app in C# that is eventually destined for IoT, but right now I've only been debugging locally. I'm using Windows.Web.Http.HttpClient
to connect to a self-hosted WCF REST web service that I've also written and have running as a Console app on the same machine for testing. The service requires mutual authentication with certificates, so I have a CA cert, service cert, and client cert.
My UWP code works like this:
- Check app cert store for client cert and CA cert installed.
- If not, install from PFX file and CER file, respectively.
- Attach the
Certificate
to theHttpBaseProtocolFilter
and add the filter to theHttpClient
- Call the
HttpClient.PostAsync
After I call PostAsync
I get the following error: An Error Occurred in the Secure Channel Support
. After plenty of searching online, and by common sense, I'm pretty sure HttpClient
is barfing because of a problem establishing the mutually-authenticated SSL connection. But based on my troubleshooting I can't figure why.
To troublshoot further, I've written a plain old Console app using System.Net.Http.HttpClient
, attached the client certificate to the request and everything works great. Sadly, System.Net
isn't fully supported on UWP. I've also tried NOT attaching the certificate to the UWP HttpClient
and the app prompts me with a UI to select an installed certificate. I select the correct cert and still get the same exception (this at least lets me know the cert is installed correctly and validating properly with the CA from the app's perspective). In additon, I hit the GET on the web service from a browser, select the client cert when prompted, and am able to download a file.
I've tried using Fiddler and, I assume because of the way it proxies traffic, it seems to work a little bit further, except my web service rejects the request as Forbidden (presumably because Fiddler is not including the correct client cert in the request). I haven't hit up Wireshark yet because it's a pain to get Wireshark to work using localhost on Windows.
My next step is to start changing the web service to not require client authentication and see if that is the problem.
Two questions: Why is Windows.Web.Http.HttClient
not working in this case? And, less important, any recommendations on good HTTP monitoring tools to help me debug this further?