To fix a bug in my application, I had to set the SecurityProtocolType of the ServicePointManager class found in the System.Net assembly like this:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
In .Net 4.5+ the SecurityProtocolType enum has four members:
public enum SecurityProtocolType
{
Ssl3 48,
Tls 192,
Tls11 768,
Tls12 3072
}
However, in .Net 4.0 the SecurityProtocolType enum has only two members:
public enum SecurityProtocolType
{
Ssl3 48,
Tls 192
}
Since, another project in my code also needed the same fix but that project was on .Net 4.0 which does not have Tls12 as a member for the enum, this answer suggested the following workaround (provided I have the .Net 4.5 installed on the same box):
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
May be I am missing smoething obvious, but my question is, how does (SecurityProtocolType)3072
get resolved to Tls12 when 3072 is not a valid value for the enum in .Net 4.0. I want to understand what magic is going on behind the scenes that makes this work.