Request aborted: Failed to create SSL/TLS secure channel

887 Views Asked by At

The program I wrote in c# works fine in local (windows 10) but on my server it gives the error "Request aborted: Failed to create SSL/TLS secure channel." . my server is windows server 2012 r2 why am i getting this error can you help me.

Could it be related to the security policies of the website I'm requesting? (There is no problem when I send requests to other websites with the code below)

This Code:

private void Form1_Load(object sender, EventArgs e)
        {
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
            | SecurityProtocolType.Tls11
            | SecurityProtocolType.Tls12
            | SecurityProtocolType.Ssl3
            | SecurityProtocolType.Tls13;
        }

I changed the tls versions. I updated the .netframework(4.8) but the result is the same, when I send a request to other sites, there is no problem from the server again.

1

There are 1 best solutions below

0
Muhammad Amin On

Follow these steps for Windows Server 2012 R2.

  1. First install all pending Windows Updates and Restart Server.
  2. Go to SSLLabs https://www.ssllabs.com/ssltest/analyze.html
  3. Enter the url of the site/api you are having problem to connect, wait a while until the test is completed
  4. Go to 'Cipher Suites' section and read very carefully TLS 1.3 / TLS 1.2. There you will find the Cipher Suites accepted by the server.
  5. Download IISCrypto GUI tool from https://www.nartac.com/Products/IISCrypto/Download
  6. Enable TLS 1.2, if it is disabled. (using IISCrypto GUI Tool)
  7. Enable additional/missing cipher suites you found in point No. 5 (using IISCrypto GUI Tool).
  8. Restart Server.

Note:- If the URL/API you are hitting doesnot support TLS 1.2 (only supports TLS 1.3). Then the only way for you to is to upgrade Windows server to at least Windows Server 2019. TLS 1.3 is not supported by Windows Server 2012 / R2