无法仅在 Windows Server 2012 上创建 SSL/TLS 安全通道

TJ *_*man 5 c# certificate tls1.2

我有一个特殊的问题,ac# app 可以在我测试过的所有其他机器和其他客户端机器上运行。但是没有在我的 ISP 托管的客户端 Windows Server 2012 上建立连接。根据我的客户的说法,这个应用程序在大约 2 天前一直在这台机器上运行,并使用 .Net4.5.2。不幸的是,我不知道过去几天发生了什么变化。

我在这台机器上测试过的:

  • 使用 Chrome 网址有效
  • 使用 Edge 网址有效
  • 使用 curl 访问 URL 有效
  • 使用IE11的网址确实工作
  • 使用我们的应用程序做工作
  • 使用快速测试应用程序不会工作

无论我在服务器或应用程序中更改什么设置,这都是一样的。

来自我的应用程序的错误:

AuthResponse is null: False 
AuthResponse ErrorException: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
   at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at RestSharp.Http.WriteRequestBody(HttpWebRequest webRequest)
   at RestSharp.Http.PostPutInternal(String method)
   at RestSharp.Http.AsPost(String httpMethod)
   at RestSharp.RestClient.DoExecuteAsPost(IHttp http, String method)
   at RestSharp.RestClient.Execute(IRestRequest request, String httpMethod, Func`3 getResponse)
AuthResponse ErrorMessage: The request was aborted: Could not create SSL/TLS secure channel.
Run Code Online (Sandbox Code Playgroud)

来自 IE11 的错误:

Turn on TLS 1.0, TLS 1.1, and TLS 1.2 in Advanced settings and try connecting to  again. If this error persists, it is possible that this site uses an unsupported protocol or cipher suite such as RC4 (link for the details), which is not considered secure. Please contact your site administrator.
Run Code Online (Sandbox Code Playgroud)

来自事件查看器的错误:

A fatal alert was received from the remote endpoint. The TLS protocol defined fatal alert code is 40.
A fatal alert was generated and sent to the remote endpoint. This may result in termination of the connection. The TLS protocol defined fatal error code is 40. The Windows SChannel error state is 1205.
A fatal error occurred while creating an SSL client credential. The internal error state is 10013.
Run Code Online (Sandbox Code Playgroud)

事件查看器中有很多这样的错误,我只是复制了其中的三个,以防它们实际上相关。

我尝试过的:

我使用IISCrypto来更改和配置各种设置和测试。所有的结果都是一样的。我已经修改了我的应用程序,并通过搜索所有相同的结果发现了很多更改。我在下面所做的一些代码更改:

System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
Run Code Online (Sandbox Code Playgroud)

这不是我尝试的所有更改。我也尝试了各种不同的变体,例如只有 tls1.2。我也使用我的小测试应用程序连接到其他 https 站点,如 google 和我的其他休息服务,这台机器上没有报告错误。

我们的 Auth 服务器使用 Lets Encrypts 证书并使用 OAth 并且只接受 tls2.1。我已经使用了另一个我们使用的 REST Api,它也使用 Lets Encrypt 并且正在运行。我不知道我是否需要更新证书存储(如果可能的话),或者是否有我遗漏的设置。老实说,我在这里不知所措。

测试应用程序源是否有帮助:

static async Task test(string url)
{
    // Call asynchronous network methods in a try/catch block to handle exceptions.
    try
    {
        HttpClient httpClient = new HttpClient();
        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

        var result = await httpClient.GetAsync(url);
        MessageBox.Show(result.StatusCode.ToString());
    }
    catch (HttpRequestException e)
    {
        MessageBox.Show(e.ToString());
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 6

我们今天也遇到了同样的问题。昨天我们的网络服务器删除了一些不安全的密码套件。尽管存在漏洞,但添加这些密码套件解决了问题。 https://learn.microsoft.com/en-us/windows-server/security/tls/manage-tls

以下是密码套件列表: https://support.microsoft.com/en-us/help/2929781/update-adds-new-tls-cipher-suites-and-changes-cipher-suite-priorities

列出支持的密码套件: https://learn.microsoft.com/nl-nl/windows/win32/secauthn/prioritizing-schannel-cipher-suites ?redirectedfrom=MSDN#listing-supported-cipher-suites