SSL TLS communication in c# with self signed certificate not working

Viewed 389

I have a .pem certificate file which is used to communicate between two servers. For communication I have written a program in C# like this:

var client = new RestClient("https://aaaaa.com:1111");
client.ClientCertificates = new X509CertificateCollection();
client.ClientCertificates.Add(new X509Certificate(@"C:\Users\aaa\Desktop\bbb.pem"));

var request = new RestRequest("/qqq/www", Method.POST);
request.AddJsonBody(new { create = new { msgBdy="Test" } });
var response = client.Execute(request);

Console.WriteLine(response.StatusCode);
//The underlying connection was closed: An unexpected error occurred on a send.

When I post the request through SoapUI it goes through, but when I try to send it through Postman or the above C# program it doesn't.

enter image description here Screenshot from wireshark is below: enter image description here

The change cipher spec event is called for the successful API call but through postman and c# application this event is never called.

I have tried to do this as explained in this article as well https://www.codeproject.com/Articles/326574/An-Introduction-to-Mutual-SSL-Authentication but that also didn't work.

How can I fix this issue.

0 Answers
Related