无法创建SSL/TLS安全通道:C# WebRequest请求失败求助
问题描述
我已经查阅过大量关于The request was aborted: Could not create SSL/TLS secure channel错误的问答,但试过所有能找到的解决方案都无效。我使用C#的WebRequest对接API时出现该错误,已尝试的操作包括:
- 将.NET版本从4.0升级至4.7.2,问题未解决
- 添加
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12配置,无效果
服务器环境
Windows Server 2019 + IIS 10
目标API的SSL配置(在线SSL测试结果)
目标系统仅启用TLS 1.3和TLS 1.2,密码套件如下:
TLS 1.3(按服务器偏好顺序)
- TLS_AES_128_GCM_SHA256 (0x1301) ECDH x25519(等效3072位RSA) FS 128
- TLS_AES_256_GCM_SHA384 (0x1302) ECDH x25519(等效3072位RSA) FS 256
- TLS_CHACHA20_POLY1305_SHA256 (0x1303) ECDH x25519(等效3072位RSA) FS 256
TLS 1.2(按服务器偏好顺序)
- TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (0xc02f) ECDH x25519(等效3072位RSA) FS 128
- TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030) ECDH x25519(等效3072位RSA) FS 256
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 (0xcca8) ECDH x25519(等效3072位RSA) FS 256
当前代码
ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13 | SecurityProtocolType.Ssl3; ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; WebRequest request = HttpWebRequest.Create(url); WebResponse response = request.GetResponse();
疑问
- 我的服务器是否支持目标API的SSL配置?
- 还有其他可尝试的解决办法吗?
内容的提问来源于stack exchange,提问作者johna
相关产品推荐
相关产品推荐

