You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法创建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();

疑问

  1. 我的服务器是否支持目标API的SSL配置?
  2. 还有其他可尝试的解决办法吗?

内容的提问来源于stack exchange,提问作者johna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 12:22:13