这是一个重要的问题。 SSL 3 协议 (1996) 被 2014 年发布的 Poodle 攻击无法挽回地破坏。IETF 发布了"SSLv3 MUST NOT be used"。网络浏览器正在抛弃它。 Mozilla Firefox 和 Google Chrome 已经这样做了。
在浏览器中检查协议支持的两个优秀工具是 SSL Lab's client test 和 https://www.howsmyssl.com/ 。后者不需要Javascript,所以你可以从.NET的HttpClient试试:
// set proxy if you need to
// WebRequest.DefaultWebProxy = new WebProxy("http://localhost:3128");
File.WriteAllText("howsmyssl-httpclient.html", new HttpClient().GetStringAsync("https://www.howsmyssl.com").Result);
// alternative using WebClient for older framework versions
// new WebClient().DownloadFile("https://www.howsmyssl.com/", "howsmyssl-webclient.html");
结果很糟糕:
您的客户端使用的是非常旧的 TLS 1.0,可能容易受到 BEAST 攻击,并且没有可用的最佳密码套件。 TLS 1.0 客户端以及更多现代密码套件无法使用 AES-GCM 和 SHA256 等替代 MD5-SHA-1 的附加功能。
这令人担忧。它与 2006 年的 Internet Explorer 7 相当。
要准确列出 HTTP 客户端支持的协议,您可以尝试以下特定于版本的测试服务器:
var test_servers = new Dictionary<string, string>();
test_servers["SSL 2"] = "https://www.ssllabs.com:10200";
test_servers["SSL 3"] = "https://www.ssllabs.com:10300";
test_servers["TLS 1.0"] = "https://www.ssllabs.com:10301";
test_servers["TLS 1.1"] = "https://www.ssllabs.com:10302";
test_servers["TLS 1.2"] = "https://www.ssllabs.com:10303";
var supported = new Func<string, bool>(url =>
{
try { return new HttpClient().GetAsync(url).Result.IsSuccessStatusCode; }
catch { return false; }
});
var supported_protocols = test_servers.Where(server => supported(server.Value));
Console.WriteLine(string.Join(", ", supported_protocols.Select(x => x.Key)));
我正在使用 .NET Framework 4.6.2。我发现 HttpClient 只支持 SSL 3 和 TLS 1.0。这很令人担忧。这与 2006 年的 Internet Explorer 7 相当。
更新: HttpClient 确实支持 TLS 1.1 和 1.2,但您必须在 System.Net.ServicePointManager.SecurityProtocol 手动打开它们。见https://stackoverflow.com/a/26392698/284795
我不知道为什么它使用坏的开箱即用协议。这似乎是一个糟糕的设置选择,相当于一个重大的安全漏洞(我敢打赌,很多应用程序都不会更改默认设置)。我们如何举报?