Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Net.SecurityProtocolType.Tls12 definition not found

Tags:

c#

.net

ssl

tls1.2

I'm trying to add the following line of code to the Global.asax file in a website project.

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

The vs2012 IntelliSense is showing that Tls12 definition exist. But the build is saying that the definition does not exist (See screen shot).

screen shot

I've tried adding System.Net.dll to the bin folder of the project, but the build still failed. Any idea how I might be able to resolve this?

like image 398
HockChai Lim Avatar asked Nov 13 '17 16:11

HockChai Lim


People also ask

What is Securityprotocoltype C#?

Definition. Specifies the security protocols that are supported by the Schannel security package. This enumeration supports a bitwise combination of its member values.

What is service point manager?

ServicePointManager is a static class used to create, maintain, and delete instances of the ServicePoint class.


1 Answers

SecurityProtocolType.Tls11 and SecurityProtocolType.Tls12 enum values are missing on Framework 4.0 only.

SecurityProtocolType numeric values:
SystemDefault (0)
Ssl3 (48 - 0x30)
Tls (192 - 0xC0)
Tls11 (768 - 0x300) missing on Framework 4.0
Tls12 (3072 - 0xC00) missing on Framework 4.0

On Framework 4.0, if want to allow TLS 1.0, 1.1 and 1.2, just replace:

SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12  

by:

(SecurityProtocolType)(0xc0 | 0x300 | 0xc00)
like image 75
figolu Avatar answered Sep 30 '22 13:09

figolu