Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TLS 1. 2 The client and server cannot communicate, because they do not possess a common algorithm

I have an issue with TLS 1.2. It works if I enable tls1.0 in client machine, but it is not recommended.

Exception is - The client and server cannot communicate, because they do not possess a common algorithmSystem.ComponentModel.Win32Exception (0x80004005): The client and server cannot communicate, because they do not possess a common algorithm.

Target Framework of my app is .NET 4.6.2.

like image 950
Ragwq Avatar asked Nov 02 '25 19:11

Ragwq


1 Answers

There are two possible scenario, in my case I used 2nd point.

  1. If you are facing this issue in production environment and you can easily deploy new code to the production then you can use of below solution.

    You can add below line of code before making api call,

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; // .NET 4.5

  2. If you cannot deploy new code and you want to resolve with the same code which is present in the production, then this issue can be done by changing some configuration setting in config file. You can add either of one in your config file.

<runtime>
    <AppContextSwitchOverrides value="Switch.System.Net.DontEnableSchUseStrongCrypto=false"/>
  </runtime>

or

<runtime>
  <AppContextSwitchOverrides value="Switch.System.Net.DontEnableSystemDefaultTlsVersions=false"
</runtime>
like image 90
Sagar Borole Avatar answered Nov 04 '25 10:11

Sagar Borole