gpt4 book ai didi

c# - XmlDocument.Load : Could not create SSL/TLS secure channel

转载 作者:太空宇宙 更新时间:2023-11-03 14:58:02 24 4
gpt4 key购买 nike

我的应用程序中散布着与此类似的简单代码:

new XmlDocument().Load("https://mybookingpal.com/xml/rest/product/organization/5?pos=" + "a3a2e74b809e0e87");

上面是新域,旧域是:

new XmlDocument().Load("https://razor-cloud.com/xml/rest/product/organization/5?pos=" + "a3a2e74b809e0e87");

您可以尝试这两个 Urls 并查看它们是否正常工作/产生相同的 XML 结果。

SSL 中可能发生了一些变化,现在阻止了 .Load() 的运行。我有两个问题:

  1. 是什么导致了失败,所以我可以尝试在一个地方(在 API 服务器上)修复它?
  2. 如何修复客户端代码?

最佳答案

我遇到了同样的问题。事实证明它是由

中定义的 xml DTD 引起的
<!DOCTYPE>

检查xml文件头

<!DOCTYPE xxx SYSTEM "url">

复制 url 并粘贴到浏览器中,然后运行 ​​Fiddler 以查看它正在使用的协议(protocol)。

我的情况是,我正在运行一个本地服务器来解析一个使用来自第 3 方的 DTD 的 xml 文件。我的本地服务器在 Tls11 或 Tls12 上运行,而第三方 DTD(url)只能通过 Ssl 或 Tls10 进行通信。所以握手失败。

我的解决方案很简单,只需添加以下行作为临时修复:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;

关于c# - XmlDocument.Load : Could not create SSL/TLS secure channel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26650174/

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