gpt4 book ai didi

Azure Web作业 "Could not create SSL/TLS secure channel"

转载 作者:行者123 更新时间:2023-12-04 08:48:26 24 4
gpt4 key购买 nike

我有一个 Azure WebJob,在本地运行时工作正常,但在 Azure 中运行时会引发异常。 WebJob 正在通过 HTTPS 进行外部调用,这在 Azure 中会产生以下异常:

System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel. at System.Net.HttpWebRequest.GetResponse()

我还尝试使用 ServicePointManager 将安全协议(protocol)设置为 TLS,但这也对异常没有影响。这是我的代码片段。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";

Azure 是否阻止 WebJobs 访问 Internet,还是我做错了什么?

最佳答案

我遇到了同样的问题,最终在 MSDN 论坛上的以下帖子的帮助下成功解决了问题:

https://social.msdn.microsoft.com/Forums/en-US/ca6372be-3169-4fb5-870f-bfbea605faf6/azure-webapp-webjob-exception-could-not-create-ssltls-secure-channel?forum=windowsazurewebsitespreview

似乎 Microsoft 上个月(2015 年 10 月)针对此问题部署了修复程序,但我还必须设置:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11;

请注意,我遗漏了 SecurityProtocol.Tls,因为它似乎不受 Microsoft 员工在 MSDN 主题的回复之一中提到的支持:

The client hello from .NET code running inside a web app shows that it is trying to use TLS v1.0 with TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA ciphers that are obviously not supported on the server. In .NET 4.5 you can ask it to use a different protocol version and then things start working for me once I do that.

关于Azure Web作业 "Could not create SSL/TLS secure channel",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30517415/

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