.net 4.5 use tls 1.2

C#
System.Net.ServicePointManager.SecurityProtocol =
    SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
Source

Also in C#: