I'm developing a program (in C# .Net v4.5.1) that needs to communicate with a 3rd party service, which requires a client certificate to authenticate. The problem is that if I enable TLS1.2 for the program, the client certificate isn't send to the service, but if I use TLS1.0, the certificate is passed to the service. I use the same function and same certificate regardless of what TLS version I use. The only thing I've changed is the TLS version. I've checked the network traffic using WireShark and the certificate is only passed along when using TLS1.0. Do I need to do anything special to when using TLS1.2 to send the certificate along the request?
I switch between TLS1.2 and TLS1.0 using the following code
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
and
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
I use the following function to call the 3rd party service
private static string GetData(string url, X509Certificate certificate, int timeOut = 5)
{
var handler = new WebRequestHandler();
handler.ClientCertificates.Add(certificate);
using (var client = new HttpClient(handler))
{
client.Timeout = new TimeSpan(0, 0, timeOut * 1000);
var result = client.GetAsync(url).Result;
string content = result.Content.ReadAsStringAsync().Result;
return content;
}
}