gpt4 book ai didi

.net - .net5.0 是否已经支持 tls1.3?

转载 作者:行者123 更新时间:2023-12-04 22:40:54 29 4
gpt4 key购买 nike

根据
Microsoft Updates Its TLS 1.3 Support Plans in Windows, Office 365 and .NET

Announcing .NET 5.0 RC 1
, 是否 .NET 5.0 RC 1已经支持 tls1.3?
如果没有,11月份肯定会支持吗?另外,在哪里可以看到官方的.net时间表。
我的测试代码:

using System;
using System.IO;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;

namespace TestTls13{
class Program {
static void Main(string[] args) {
RemoteCertificateValidationCallback certificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => {
return (true);
};
using(MemoryStream msClient = new MemoryStream()) {
using(MemoryStream msServer = new MemoryStream()) {
using(SslStream sslStreamClient = new SslStream(msClient, false, certificateValidationCallback)) {
using(SslStream sslStreamServer = new SslStream(msServer, false, certificateValidationCallback)) {
Task taskClient = Task.Run(() => {
sslStreamClient.AuthenticateAsClient("nord-IT-systeme GmbH", new X509CertificateCollection() { CreateCert(), }, SslProtocols.Tls13, false);
});
Task taskServer = Task.Run(() => {
sslStreamServer.AuthenticateAsServer(CreateCert(), false, SslProtocols.Tls13, false);
});
Task.WaitAll(taskClient, taskServer);
}
}
}
}
}
static X509Certificate2 CreateCert() {
ECDsa ecdsa = ECDsa.Create();
CertificateRequest req = new CertificateRequest("CN=nord-IT-systeme GmbH", ecdsa, HashAlgorithmName.SHA256);
X509Certificate2 cert = req.CreateSelfSigned(DateTimeOffset.Now, DateTimeOffset.Now.AddYears(5));
return (cert);
}
}
}
异常(exception):
enter image description here
这个异常是因为它还不支持tls1.3吗?
我的电脑中的 TLS 信息
enter image description here

最佳答案

TL;博士
是的,但底层操作系统必须支持它。
在您的情况下,you have to enable it in the registry因为它默认是禁用的。
细节
这取决于底层操作系统。
.NET 使用基于操作系统的不同实现,例如Linux 上的 OpenSSL,Windows 上的 Schannel
从 .NET Core 3.0 开始支持 TLS 1.3,如 you can read from the docs .
.NET Core 3.0 时的声明will be modified shortly :

Windows and macOS do not yet support TLS 1.3. .NET Core 3.0 will support TLS 1.3 on these operating systems when support becomes available.


Windows 支持 TLS 1.3 since version 1903 ,但默认情况下它是禁用的。
还有另一个问题回答了如何在 Windows 上启用它:
how to enable TLS 1.3 in windows 10
从 Build 20170 开始,Windows 10 Insider Preview 版本默认启用 TLS 1.3:
Taking Transport Layer Security (TLS) to the next level with TLS 1.3
根据这篇文章:

TLS 1.3 support will also be added to .NET beginning with version 5.0.


karelz 在 GitHub 上对当前流程进行了很好的总结(这个问题也应该跟踪 .NET Framework 何时获得支持):
https://github.com/dotnet/docs/issues/4675#issuecomment-678421120

关于.net - .net5.0 是否已经支持 tls1.3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64022167/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com