C# "The request was aborted: the SSL/TLS secure channel could not be created" general solution

There are two ways

The first one: before executing the code, add

 ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;

The second method, adding this paragraph is also fine. You can choose one of these two methods. If there is an error, please switch the project to net4.5 or above.

//http load certificate, ssl, if error occurs, switch to net4.5
            ServicePointManager.Expect100Continue = true;
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
 //http load certificate, ssl, if error, Just switch to net4.5

You can get the content of the https link normally, or download the file with the https link

Can be solved:

C# failed to create SSL/TLS secure channel

C# appears that the underlying connection has been closed: an error occurred while receiving

C# cannot request the content of the https link

Guess you like

Origin blog.csdn.net/Lccee/article/details/125799950