I created a .NET Core console app that performs exactly what I need: send a RestSharp request with an attached certificate. Everything works fine. Here's the code:
static void Main(string[] args)
{
var client = new RestSharp.RestClient();
client.ClientCertificates = new X509CertificateCollection();
client.ClientCertificates.Add(new X509Certificate2(@"C:\Users\kid_j\Downloads\badssl.com-client.p12", "badssl.com"));
var result = client.Execute(new RestSharp.RestRequest("https://client.badssl.com/", RestSharp.Method.GET));
Console.WriteLine(result.StatusCode);
}
But when I place that same code inside a UWP app, it does not work. I get this error message:
An error occurred while sending the request. Client certificate was not found in the personal (\"MY\") certificate store. In UWP, client certificates are only supported if they have been added to that certificate store.
I've tried double clicking on the certificate file and installing the cert, but I am still getting the same issue.
Any ideas what's going on?
Out of sheer desperation, I enabled Shared User Certificates
in the capabilities section of my app's package manifest. It worked! Hopefully this helps others!