I just can't see what I'm doing wrong. I have a certificate that I obtained (not self signed). I have a pfx file and a password. I added the certificate in Postman and the API call works. I try to add the same certificate using RestSharp and it fails - the server returns a 400 error with a message saying no SSL certificate was supplied.
public void AttachCertificate(RestClient client)
{
try
{
X509Certificate2 cert = new X509Certificate2(@"C:\...\xxx.pfx", "-password-");
if (client.Options.ClientCertificates == null) client.Options.ClientCertificates = new X509CertificateCollection();
if (cert != null) client.Options.ClientCertificates.Add(cert);
} catch(Exception ex)
{
var x = ex;
}
}
I can see the certificate is there (in RestClient.Options.ClientCertificates) in debugger after this code runs. This is in .Net Core 3.1