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

Kuler Master 266 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.

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,551 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,479 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,899 questions
ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
335 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 64,826 Reputation points
    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.