.NET 6中SslStream.AuthenticateAsServer用RSA 4096密钥时性能缓慢
.NET 6 HTTPS服务器TLS握手延迟优化需求
我有一个基于.NET 6的HTTPS服务器应用,采用TCPclient网络组件及SslStream.AuthenticateAsServer接口。通过Wireshark抓包观测发现,在JMeter 50线程发送约10KB payload的HTTPS请求负载场景下,服务器收到“Client hello”后,发送“server hello, Certificate, Server key Exchange, Server hello Done”这组握手报文存在约4秒的延迟。
经测试发现,密钥长度(2048位与4096位)会直接影响该延迟时长,当前服务器密钥通过以下OpenSSL命令生成:
openssl genrsa -out priKey.pem 4096
已定位到延迟来源于以下代码行:
sslstream.AuthenticateAsServer(serverCert, false, System.Security.Authentication.SslProtocols.Tls | System.Security.Authentication.SslProtocols.Tls11 | System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls13, false);
该行代码负责执行TLS握手流程,依赖.NET 6原生API,无法直接修改实现逻辑,现寻求可优化该延迟的替代方案或配置参数。
服务器硬件配置:
- CPU:Intel Atom® Processor C3758
- RAM:8GB DDR4
内容的提问来源于stack exchange,提问作者JL007
相关产品推荐
相关产品推荐

