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.ServicePointManager.SecurityProtocol = SecurityProtocolTypeExtensions.Tls12;
in my Global.asax
in Application_Start
but it is giving me compile time error that
The name 'SecurityProtocolTypeExtensions' does not exist in the current context
I was following this link Support for TLS System Default Versions included in the .NET Framework 3.5.1 on Windows 7 SP1 and Server 2008 R2 SP1 provided by Microsoft.
Update 1:
Also tried as told in above link, added both files in project, now I am getting an exception "System.NotSupportedException
: The requested security protocol is not supported"
Updated 2:
Tried as suggested by Jon Davies, but still no luck. same Exception System.NotSupportedException
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With