title: Using HttpClient & HttpWebRequest for Https TLS1.2
body: <p>In Console Application, while trying to hit the "https" Endpoint configured with TLS 1.2.</p>
  
  <p>In C#
  While using HttpClient I am getting the success response from endpoint</p>
  
  <pre><code>       HttpClient httpClient = new HttpClient();
  
          //specify to use TLS 1.2 as default connection
          System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
  
          httpClient.BaseAddress = new Uri("HTTPSENDPOINT");
          httpClient.DefaultRequestHeaders.Accept.Clear();
          httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
          var content = new StringContent("POSTDATA");
          var task = httpClient.PostAsync("/Token", content);
  
          task.Wait();
  
          Console.WriteLine(task.Result.Content.ReadAsStringAsync().Result.ToString());
  </code></pre>
  
  <p>But when using HttpWebRequest </p>
  
  <pre><code>       var request = (HttpWebRequest)WebRequest.Create("HTTPSENDPOINT/Token");
         var postData = "POSTDATA";
          var data = Encoding.ASCII.GetBytes(postData);
  
          System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
          request.Method = "POST";
          request.ContentType = "application/x-www-form-urlencoded";
          request.ContentLength = data.Length;
  
          using (var stream = request.GetRequestStream()) // Getting Error in GetRequestStream() method call
          {
              stream.Write(data, 0, data.Length);
          }
  
          var response = (HttpWebResponse)request.GetResponse();
  
          var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
  </code></pre>
  
  <p>I am getting below error</p>
  
  <pre><code>The request was aborted: Could not create SSL/TLS secure channel.
  </code></pre>
  
  <p>Please guide me what I am doing wrong while using HttpWebRequest?</p>