无法仅在 Windows Server 2012 上创建 SSL/TLS 安全通道
Could not create SSL/TLS secure channel only on Windows Server 2012
我有一个特殊的问题,即 C# 应用程序可以在我测试过的所有其他机器和其他客户端机器上运行。但是没有在他的 ISP 托管的我的客户端 Windows Server 2012 上建立连接。根据我的客户,这个应用程序大约 2 天前在这台机器上运行,并使用 .Net4.5.2。不幸的是,我不知道最近几天发生了什么变化。
我在本机测试过的:
- 使用 Chrome url 有效
- 使用 Edge url 有效
- 用 curl 命中 URL 有效
- 使用 IE11 url 不 工作
- 使用我们的应用程序无效
- 使用快速测试应用不工作
无论我在服务器或应用程序中更改什么设置,这都是一样的。
我的应用程序出错:
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.
来自 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.
来自事件查看器的错误:
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.
事件查看器中有很多这样的错误,我只是复制了其中三个,以防它们确实相关。
我试过的:
我使用 IISCrypto 更改和配置所有方式的设置和测试。结果都一样。我已经修改了我的应用程序,并通过搜索所有结果相同的结果发现了很多变化。我在下面所做的一些代码更改:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
这不是我尝试的所有更改。我也尝试了各种不同的变体,比如只有 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());
}
}
我们今天遇到了同样的问题。
昨天在我们的网络服务器上删除了一些不安全的密码套件。
尽管存在漏洞,但添加这些密码套件解决了问题。
https://docs.microsoft.com/en-us/windows-server/security/tls/manage-tls
我也遇到了这样的问题,找了一段时间,有几件事需要你做:
首先检查 url 您需要 access/query,Url 使用哪种类型的“加密连接”?简单的方法是通过 Mozila 或 Chrome 打开 url 然后检查“连接加密”
this example for my case
然后尝试在 https://docs.microsoft.com/en-us/windows/win32/secauthn/tls-cipher-suites-in-windows-8-1 搜索可用于 Windows Server 2012 的可用 TLS 密码。找到第一步中的“Connection Encrypted”,对于第 2 步,如果找不到“Cipher suite string”,则意味着您的服务器无法通过 C# 代码调用 url。
即使您在代码中设置了它。
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
因为 Windows Server 2012 不支持“连接加密”
希望对您有所帮助。
你可能已经解决了这个问题,但我刚刚遇到了同样的问题,外部 api 调用由于“无法创建 SSL/TLS 安全通道”的相同错误而失败。
我花了两天时间修复它,首先使用 https://www.ssllabs.com/ssltest/
检查端点支持的 TLS 版本和密码
之后,我使用 IIS Crypto 相应地启用了正确的密码,按照 SSLLabs 提供的顺序重新排列密码并解决了问题。
也许这会对某人有所帮助。
我刚刚在使用 Windows Server 2019 Datacenter 时遇到了这个问题。
我用来保护我在服务器上的自托管服务的 X.509 证书很旧而且很弱,RSA 1024,MD5 哈希。
事件查看器对追查原因没有帮助。
凭直觉,我用更新的 X.509、RSA 4096、SHA256 替换了旧的 X.509,错误消失了。
我有一个特殊的问题,即 C# 应用程序可以在我测试过的所有其他机器和其他客户端机器上运行。但是没有在他的 ISP 托管的我的客户端 Windows Server 2012 上建立连接。根据我的客户,这个应用程序大约 2 天前在这台机器上运行,并使用 .Net4.5.2。不幸的是,我不知道最近几天发生了什么变化。
我在本机测试过的:
- 使用 Chrome url 有效
- 使用 Edge url 有效
- 用 curl 命中 URL 有效
- 使用 IE11 url 不 工作
- 使用我们的应用程序无效
- 使用快速测试应用不工作
无论我在服务器或应用程序中更改什么设置,这都是一样的。
我的应用程序出错:
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.
来自 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.
来自事件查看器的错误:
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.
事件查看器中有很多这样的错误,我只是复制了其中三个,以防它们确实相关。
我试过的:
我使用 IISCrypto 更改和配置所有方式的设置和测试。结果都一样。我已经修改了我的应用程序,并通过搜索所有结果相同的结果发现了很多变化。我在下面所做的一些代码更改:
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
这不是我尝试的所有更改。我也尝试了各种不同的变体,比如只有 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());
}
}
我们今天遇到了同样的问题。 昨天在我们的网络服务器上删除了一些不安全的密码套件。 尽管存在漏洞,但添加这些密码套件解决了问题。 https://docs.microsoft.com/en-us/windows-server/security/tls/manage-tls
我也遇到了这样的问题,找了一段时间,有几件事需要你做:
首先检查 url 您需要 access/query,Url 使用哪种类型的“加密连接”?简单的方法是通过 Mozila 或 Chrome 打开 url 然后检查“连接加密” this example for my case
然后尝试在 https://docs.microsoft.com/en-us/windows/win32/secauthn/tls-cipher-suites-in-windows-8-1 搜索可用于 Windows Server 2012 的可用 TLS 密码。找到第一步中的“Connection Encrypted”,对于第 2 步,如果找不到“Cipher suite string”,则意味着您的服务器无法通过 C# 代码调用 url。
即使您在代码中设置了它。
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
因为 Windows Server 2012 不支持“连接加密”
希望对您有所帮助。
你可能已经解决了这个问题,但我刚刚遇到了同样的问题,外部 api 调用由于“无法创建 SSL/TLS 安全通道”的相同错误而失败。
我花了两天时间修复它,首先使用 https://www.ssllabs.com/ssltest/
检查端点支持的 TLS 版本和密码之后,我使用 IIS Crypto 相应地启用了正确的密码,按照 SSLLabs 提供的顺序重新排列密码并解决了问题。
也许这会对某人有所帮助。
我刚刚在使用 Windows Server 2019 Datacenter 时遇到了这个问题。
我用来保护我在服务器上的自托管服务的 X.509 证书很旧而且很弱,RSA 1024,MD5 哈希。
事件查看器对追查原因没有帮助。
凭直觉,我用更新的 X.509、RSA 4096、SHA256 替换了旧的 X.509,错误消失了。