title: How to use TLS 1.2 in ASP.NET Core 2.0
body: <p>My salesforce res apis were working fine until. When suddenly I started getting authentication errors. <strong>retry your request.</strong>
  <strong>Salesforce.Common.AuthenticationClient.d__1.MoveNext()</strong>.</p>
  
  <p>salesforce informed that it would use from now TLS .1.2. How can I enforce my asp.net core 2.0 to use TLS 1.2 in Startup.cs. below is my code for login.</p>
  
  <pre><code> private async Task&lt;AuthenticationClient&gt; GetValidateAuthentication()
          {
              RestApiSetting data = new RestApiSetting(Configuration);
              var auth = new AuthenticationClient();
              var url = data.IsSandBoxUser.Equals("true", StringComparison.CurrentCultureIgnoreCase)
                  ? "https://test.salesforce.com/services/oauth2/token"
                  : "https://login.salesforce.com/services/oauth2/token";
              try
              {
                  //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                  await auth.UsernamePasswordAsync(data.ConsumerKey,
                  data.ConsumerSecret, data.Username, data.Password, url);
                  return auth;
              }
              catch (Exception ex)
              {
                  throw new Exception(ex.ToString());
              }
          }
  </code></pre>