System.Net.WebException: "Request aborted: Failed to create SSL/TLS secure channel."

1. Problem description

When using the HttpWebRequest.GetResponse() method to make an HTTPS request, a System.Net.WebException: Request aborted: Failed to create an SSL/TLS secure channel exception may occur. This is usually due to the TLS connection between the client and the server. Caused by version incompatibility.

2. Solution

1.指定 TLS 版本: You can specify the TLS version used by setting the ServicePointManager.SecurityProtocol property in code. For example:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

TLS version 1.2 is used here to make requests. You can try changing different TLS versions to see if the problem can be solved.

2.更新 .NET Framework 版本: If you are using an older version of .NET Framework, you can try updating it to the latest version to solve the problem. After .NET Framework 4.6.2, the system uses TLS version 1.2 by default for HTTPS requests.

Guess you like

Origin blog.csdn.net/qq_29242649/article/details/129405666