向外部API发送SOAP请求时出现SSL/TLS安全通道创建失败问题
.NET调用外部SOAP API时SSL/TLS安全通道创建失败问题
- 向外部API发送SOAP请求时,出现**"Could not create SSL/TLS secure channel"**错误
- 该请求在SoapUI中可正常运行,但在.NET Framework 4.6.2应用中始终失败,无论是否附加X509证书都会触发相同错误
已尝试的解决操作
- 切换至.NET Framework 4.8.1和.NET 6.0版本,问题依旧存在
- 结合
ServicePointManager.Expect100Continue = true;,尝试设置不同的TLS通信版本:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13; ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
- 使用Tls12和Tls11时,服务器返回原错误;使用Tls13和Ssl3时,出现**"Win32Exception: 客户端和服务器无法通信,因为它们没有共同的算法"**错误,推测应使用Tls12或Tls11协议
- 重载
ServicePointManager.ServerCertificateValidationCallback并使其始终返回true,未解决问题 - 将注册表中的"SchUseStrongCrypto"标志设置为"1",无效(设置界面截图:
)
内容的提问来源于stack exchange,提问作者Max22
相关产品推荐
相关产品推荐

