RestSharp 105.2.3 https://api.eu.apiconnect.ibmcloud.com "The underlying connection was closed"

RestSharp 105.2.3 https://api.eu.apiconnect.ibmcloud.com "The underlying connection was closed"

我实际上面临一个问题,即使用 RestSharp 版本 105.2.3 调用 ibmcloud Web 服务以使用 .NET 4.0 项目。

var client = new RestClient("https://api.eu.apiconnect.ibmcloud.com");
var request = new RestRequest();
var response = client.Execute(request);

此调用出错

"La connexion sous-jacente a été fermée : Une erreur inattendue s'est produite lors de l'envoi." 

对应的英文错误是

"The underlying connection was closed"

当使用简单的浏览器时,我得到

<errorResponse><httpCode>404</httpCode><httpMessage>Not Found</httpMessage><moreInformation>The requested URL was not found on this server</moreInformation></errorResponse>

当我使用版本 106.5.4 进行简单测试时,它工作正常。

你能帮我知道这两个版本之间有什么区别吗?是否可以让这个调用在 .Net 4.0 中工作?

谢谢

我终于在这个页面找到了答案The request was aborted: Could not create SSL/TLS secure channel

在 .NET 4.5 中对此的解决方案是

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

如果您没有 .NET 4.5,请使用

ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;