I am trying run a simple console app with 2-way SSL. I have the following C# code:
var certificate = X509Certificate2.CreateFromPemFile(_publicFilename, _privateFilename);
using (var handler = new HttpClientHandler())
{
handler.ClientCertificateOptions = ClientCertificateOption.Manual;
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true;
handler.ClientCertificates.Add(certificate);
handler.SslProtocols = SslProtocols.Tls12;
using (var client = new HttpClient(handler))
{
var postData = new StringContent("", UnicodeEncoding.UTF8, "application/json");
var response = await client.PostAsync("URL", postData);
string responseString = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseString);
}
}
This fails during SSL handshake. And I get the following SChannel error on event viewer:
A fatal error occurred while creating a TLS client credential. The internal error state is 10013.
I found the following in wireshark when I run the C# console app:
However if I use the same certificates on postman, it works fine. Refer wireshark screenshot for postman request below:
On checking the signature algorithms of "Certificate Request, Server Hello Done". I get the following:
I do not understand SSL/cryptography etc that well. But as per this post : "https://github.com/dotnet/runtime/issues/33708#issuecomment-600650819" is my C# app unable to negotiate a cipher suite? Are the cipher suites mentioned in the above screenshot not supported by SChannel? I am completely lost here. Cant get a simple HTTP call due to SSL handshake fail.
Framework : .Net5.0 Operating System: Windows 10 Home (Build: 19042.985)
Please help.