SecurityProtocolTypeExtensions.Tls12; does not exist in current context

后端 未结 2 1819
孤城傲影
孤城傲影 2021-01-13 10:43

I am updating Security protocols to my existing 3.5 .net framework application to work my payment gateways smooth. I have added following code

System.Net         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-13 10:52

    The fix is stated in the article you linked to:

    To include the support for TLS v1.2, include the source files in your project...

    In other words - you need to add the SecurityProtocolTypeExtensions and SslProtocolExtensions types from the article to your own project.

    It's a bit of an ugly hack, but is required because TLS 1.2 was released after .NET 3.5.

    Alternatively if you want to avoid using these extensions and don't mind unlabelled magic numbers in your code, you could ignore the code in the article and just set this instead:

    System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType)0x00000C00;
    

提交回复
热议问题