title: HttpClientHandler / The request was aborted: Could not create SSL/TLS secure channel
body: <p>The server team says that everything is fine with this HTTPS website, however the below code when using HTTPClient gives back "<strong>The request was aborted: Could not create SSL/TLS secure channel.</strong>" error and at the same time works perfectly fine by returning back the intended data.</p>
  
  <pre><code>public async Task&lt;string&gt; GetDataAsync(string baseAddress, string relativeAddress, string token)
  {
      string responseBodyAsText = string.Empty;
      string responseStatusCode = string.Empty;
      try
      {
          using (HttpClientHandler handler = new HttpClientHandler())
          {
              handler.Credentials = new NetworkCredential(token, token);
              using (HttpClient client = new HttpClient(handler))
              {
                  client.BaseAddress = new Uri(baseAddress);
                  client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
                  using (HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, relativeAddress))
                  {
                      using (HttpResponseMessage response = await client.SendAsync(request))
                      {
                          responseBodyAsText = await response.Content.ReadAsStringAsync();
                          responseStatusCode = ReturnStatusCode(response);
                      }
                  }
              }
          }
      }
      catch (Exception e)
      {
          responseBodyAsText = BuildErrorMessage("response", "error", e.InnerException.Message, responseStatusCode);
      }
      return responseBodyAsText;
  }
  </code></pre>
  
  <p>In order to approach this issue in a different way I wrote another method which uses HTTPWebRequest and HTTPWebResponse. This code never gave me this error until now "The request was aborted: Could not create SSL/TLS secure channel."; However I wanted to post this out to find what would be the possible issue?</p>
  
  <pre><code>    public async Task&lt;string&gt; GetDataAsync(string url, string token)
      {
          string responseString = string.Empty;
          try
          {
              HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url.Trim());
              request.Method = "GET";
              request.ContentType = "application/xml";
              request.Headers[HttpRequestHeader.Authorization] = GetAuthorizationText(token.Trim());
  
              var response = (HttpWebResponse)await request.GetResponseAsync();
              if (response != null)
              {
                  var responseStream = new StreamReader(response.GetResponseStream());
                  responseString = await responseStream.ReadToEndAsync();
                  if (responseString.Trim().Length == 0)
                      throw new InvalidDataException("No Content");
              }
              else
                  throw new NullReferenceException("Reponse is null");
          }
          catch (WebException we)
          {
              responseString = BuildErrorMessage("response", "error", we.Response.Headers["Status"].ToString());
          }
          catch (Exception ex)
          {
              WriteDiagnosticsInformation(ex);
              responseString = BuildErrorMessage("response", "error", ex.Message);
          }
  
          return responseString;
      }
  </code></pre>
  
  <p>Please do share your thoughts, however I doubt may be its the issue with using HTTPClient.</p>