Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Error in Console App:"The request was aborted: Could not create SSL/TLS secure channel."

Error in Console App:"The request was aborted: Could not create SSL/TLS secure channel."

Scheduled Pinned Locked Moved C#
csharpsecurityjsonquestionasp-net
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    QuickDeveloper
    wrote on last edited by
    #1

    Hi All I am calling a REST API from my C# Console application and get the following error while calling GetResponse method "The request was aborted: Could not create SSL/TLS secure channel." The code has worked before couple of days back , so I am not sure what changed. The cert I am using is valid cert installed on my machine where I run the code, I checked the expiration details and all. My code is as follows, it fails in the try block below.The uri that I pass is this -https://management.core.windows.net/{0}/services/hostedservices[^] I replace the {0} with a valid id ofcourse. Code:

    public static XDocument GetResponse(Uri uri)
    {
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
    request.Method = "GET";
    request.Headers.Add("x-ms-version", msVersion);
    request.ClientCertificates.Add(certificate);
    request.ContentType = "application/xml";

            XDocument responseBody = null;
            HttpWebResponse response;
    
            try
            {
                **response = **(HttpWebResponse)request.GetResponse();****
            }
         catch (WebException ex)
     {
         response = (HttpWebResponse)ex.Response;
     }
    

    }

    Exception: The complete exception is: System.Net.WebException was caught HResult=-2146233079 Message=The request was aborted: Could not create SSL/TLS secure channel. Source=System StackTrace: at System.Net.HttpWebRequest.GetResponse() at StorageAccountsExtractor.AzureService.GetResponse(Uri uri) in e:\StorageAccountsRetriever\StorageAccountsExtractor\StorageAccountsExtractor\Program.cs:line 289 InnerException: Solution: I looked on the web and looks like I need to make HTTPS use TLS? how do I do that.Any other ideas that I could look into?

    "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

    B 1 Reply Last reply
    0
    • Q QuickDeveloper

      Hi All I am calling a REST API from my C# Console application and get the following error while calling GetResponse method "The request was aborted: Could not create SSL/TLS secure channel." The code has worked before couple of days back , so I am not sure what changed. The cert I am using is valid cert installed on my machine where I run the code, I checked the expiration details and all. My code is as follows, it fails in the try block below.The uri that I pass is this -https://management.core.windows.net/{0}/services/hostedservices[^] I replace the {0} with a valid id ofcourse. Code:

      public static XDocument GetResponse(Uri uri)
      {
      HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
      request.Method = "GET";
      request.Headers.Add("x-ms-version", msVersion);
      request.ClientCertificates.Add(certificate);
      request.ContentType = "application/xml";

              XDocument responseBody = null;
              HttpWebResponse response;
      
              try
              {
                  **response = **(HttpWebResponse)request.GetResponse();****
              }
           catch (WebException ex)
       {
           response = (HttpWebResponse)ex.Response;
       }
      

      }

      Exception: The complete exception is: System.Net.WebException was caught HResult=-2146233079 Message=The request was aborted: Could not create SSL/TLS secure channel. Source=System StackTrace: at System.Net.HttpWebRequest.GetResponse() at StorageAccountsExtractor.AzureService.GetResponse(Uri uri) in e:\StorageAccountsRetriever\StorageAccountsExtractor\StorageAccountsExtractor\Program.cs:line 289 InnerException: Solution: I looked on the web and looks like I need to make HTTPS use TLS? how do I do that.Any other ideas that I could look into?

      "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      If it was working a couple of days ago it's almost certainly that something has expired, either your SSL certificate, the server's certificate (though that is unlikely if you're using a hosted service), your user name or API key.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups