我目前正在使用Flurl,并尝试联系一个https API(我在实验室里)。
由于证书无效,Flurl无法继续工作 :/
这是我的错误消息:
Unhandled Exception: System.AggregateException: One or more errors occurred. (Call failed. The SSL connection could not be established, see inner exception. POST https://IP/api/aaaLogin.json) ---> Flurl.Http.FlurlHttpException: Call failed. The SSL connection could not be established, see inner exception. POST https://IP/api/aaaLogin.json ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.
在Flurl文档中,我们可以使用using Flurl.Http.Configuration;
并修改DefaultHttpClientFactory
。然而,我不理解所指定的元素以及如何处理错误。在网上,我看到了相同的情况:https://github.com/tmenier/Flurl/issues/365。您是否有关于这个问题的解决方案?谢谢!
public class UntrustedCertClientFactory:DefaultHttpClientFactory { public override HttpMessageHandler CreateMessageHandler()=> new HttpClientHandler { ServerCertificateCustomValidationCallback =(a,b,c,d)=> true }; }
- Digitag