How to troubleshoot the exception, Could not create TLS secure channel?

Kuler Master 406 Reputation points
2024-07-12T14:24:34.8133333+00:00

Hello there,

I have this C# code that consumes a SOAP WS and it was working properly for years. However, since recently it started to throw the following exception:

The request was aborted: Could not create SSL/TLS secure channel.

Basically it imports the certificate FILE (.pfx) needed for authentication.

request.ClientCertificates.Add(new X509Certificate(certificateFile, certPassword));

Well, it works 9 times as expected and then the 10th time it will not add the certificate. This results in getting Error 403 (Forbidden).

Honestly, I have no clue how to troubleshoot this issue especially because it happens only sporadically.

I checked the IIS Logs and found nothing helpful.

Your comments and suggestions would be greatly appreciated.

Developer technologies ASP.NET ASP.NET Core
Developer technologies ASP.NET ASP.NET API
Developer technologies ASP.NET Other
Developer technologies C#
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-09-05T16:48:06.3966667+00:00

    I'm not sure why you are reading the cert from disk every time (this may be the issue if concurrent requests). why not cache?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.