我有一个使用 HTTP API 在 Xamarin Forms 中构建的移动应用程序,它工作得很好,但是当 HTTP API 移动到 HTTPS 时,我开始收到 SSL 异常
有什么办法可以解决这个问题吗?
private HttpClient GetClient(HttpClientHandler handler = null)
{
try
{
IProxyInfoProvider _proxyInfoProvider = DependencyService.Get<IProxyInfoProvider>();
HttpClientHandler handlerClient = new HttpClientHandler()
{
Proxy = _proxyInfoProvider.GetProxySettings()
};
handlerClient.UseProxy = true;
//ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
// handlerClient.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
HttpClient client = new HttpClient(handlerClient
return client;
}
catch (Exception ex)
{
throw;
}
}
我无法使用服务点管理器或服务器证书自定义验证回调,因为该项目是 PCL 格式和目标“.NET Framework 4.5”