【发布时间】:2021-07-20 16:38:23
【问题描述】:
我知道这是重复的,但我已经阅读了所有关于此的文章并实施了所有建议,但我仍然无法在我的环境中解决它。
我正在运行 Windows 7 Professional 64Bit - Service Pack 1
连接到使用(取自 IE)具有 256 位加密(高)的 TLS 1.2 AES 的公共网站;具有 256 位交换的 ECDH
我在注册表中设置了不同的 SCHANNEL\Protocols 组合,包括
TLS 1.0\Client\Enabled=0 + DisabledByDefault=1
TLS 1.1\Client\Enabled=0 + DisabledByDefault=1
TLS 1.2\Client\Enabled=1 + DisabledByDefault=0
我有一个使用 .NET Framework 4.6.1 的 C# 测试应用程序,同时尝试 HttpClient 和 HttpWebRequest
'''
private void cmdGo_Click(object sender, EventArgs e)
{
ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return true; };
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(txtUrl.Text);
httpRequest.Method = "POST";
try
{
HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
}
catch (Exception exRes)
{
System.Text.StringBuilder msg = new StringBuilder();
Exception child = exRes.InnerException;
msg.AppendLine(exRes.Message);
while (child != null)
{
msg.AppendLine(child.Message);
child = child.InnerException;
}
MessageBox.Show(msg.ToString());
}
}
private void cmdNewGo_Click(object sender, EventArgs e)
{
ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return true; };
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
try
{
using (HttpClient client = new HttpClient())
{
using (HttpResponseMessage response = client.GetAsync(txtUrl.Text).GetAwaiter().GetResult())
{
if (response.IsSuccessStatusCode)
{
string output = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
MessageBox.Show(output);
}
}
}
}
catch(Exception ex)
{
System.Text.StringBuilder msg = new StringBuilder();
Exception child = ex.InnerException;
msg.AppendLine(ex.Message);
while(child != null)
{
msg.AppendLine(child.Message);
child = child.InnerException;
}
MessageBox.Show(msg.ToString());
}
}
'''
无论我尝试什么注册表设置组合或我添加的 SecurityProtocolType 值似乎都无法强制使用 TLS 1.2。
错误总是:请求被中止:无法创建 SSL/TLS 安全通道
我错过了什么或我做错了什么?
提前致谢。
【问题讨论】:
-
您是否安装了相关更新? support.microsoft.com/en-us/topic/… 我可以温和地建议升级到受支持的 Windows 版本
-
TLS Cipher Suites in Windows 7 -- Windows 7 不支持一些新的(er) 密码套件(并且永远不会,正式地,因为非 ESU 客户的安全更新不久前停止了)。 -- Web 浏览器带来(和处理)它们自己的密码套件。
-
@Charlieface 谢谢你的链接。我将查看是否已应用此更新。是的,我们迫切需要升级到正在进行中的操作系统
-
@Jimi 也感谢您提供的链接。我也在寻找这种类型的答案,看看我们是否超出了可编码的修复范围。我将查看链接中的密码套件,看看提供给我们的新列表是否包含这些
-
不能肯定地告诉你,但大多数情况下,如果你对 Windows 10 进行就地升级,它只会使用 Win7 许可证密钥
标签: c# ssl windows-7 httpclient tls1.2