The request was aborted: unable to create SSL / TLS secure channel

Keywords: SSL Windows encoding ascii

We were unable to connect to the HTTPS server using WebRequest due to the following error message:

The request was aborted: Could not create SSL/TLS secure channel.

We know that the server does not have a valid HTTPS Certificate in the path used, but in order to bypass this problem, we used the following code obtained from another StackOverflow post:

private void Somewhere() {
    ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AlwaysGoodCertificate);

private static bool AlwaysGoodCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors) {
   return true;

The problem is that the server will never validate the certificate and will fail due to the above errors. Who knows what I should do?

I should mention that a colleague and I tested it a few weeks ago, and similar to what I wrote above, it worked well. The only "major difference" we found was that I used Windows 7, and he used Windows XP. Will that change?

#1 building

Another possibility is that the certificate on the box is not entered correctly. Make sure the circled check box is selected. I didn't do this initially, so the code either timed out or threw the same exception as it couldn't find the private key.

#2 building

As you know, there may be many reasons. Thought I would add the reason why I met

This exception is thrown if the value of WebRequest.Timeout is set to 0. Here is my code... (in addition to hard coding the timeout value to 0, I have a parameter that is accidentally set to 0).

WebRequest webRequest = WebRequest.Create(@"https://myservice/path");
webRequest.ContentType = "text/html";
webRequest.Method = "POST";
string body = "...";
byte[] bytes = Encoding.ASCII.GetBytes(body);
webRequest.ContentLength = bytes.Length;
var os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
webRequest.Timeout = 0; //setting the timeout to 0 causes the request to fail
WebResponse webResponse = webRequest.GetResponse(); //Exception thrown here ...

#3 building

If the server is returning an unauthorized HTTP 401 response to an HTTP request, an "request aborted: unable to create SSL / TLS secure channel" exception occurs.

You can determine if this is happening by opening the trace level System.Net logging for the client application, such as The answer .

After logging is set up, run the application and reproduce the error, then look for the following lines in the logging output:

System.Net Information: 0 : [9840] Connection#62912200 - Received status line: Version=1.1, StatusCode=401, StatusDescription=Unauthorized.

In my case, I was unable to set a specific cookie that the server expected, which caused the server to respond to the request with a 401 error, resulting in an "unable to create SSL / TLS secure channel" exception.

#4 building

I'm trying to visit When This is CloudFlare's image distributed on CDN, which supports crazy things like SPDY and strange redirected SSL certificates.

Instead of specifying Ssl3 as in the Simons answer, I can fix it by dropping to Tls12 like this:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
new WebClient().DownloadData("");

#5 building

As long as this is a relatively "live" link, I want to add a new option. This possibility is due to a problem with the Poodle attack, which no longer supports SSL 3.0. View a Google statement about this content. I ran into this problem on several Web services at a time and realized that it had to continue. I switched to TLS 1.2 and everything was back.

Posted by Phsycoslaya on Tue, 03 Mar 2020 20:40:06 -0800