gpt4 book ai didi

ios - Xamarin - 尝试从 SSL 网站 (WebClient) 下载字符串时出错

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

我有一个由 Xamarin Studio 开发的 iOS 应用程序。当我尝试从服务器获取字符串时出现以下异常。

Exception in Class: WebClient 
Line : 271
and Method:DownloadDataCore
with message Error: SendFailure (Error writing headers)
Stack Trace: at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:971
at System.Net.HttpWebRequest.GetResponse () [0x0000e] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:985
at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/WebClient.cs:1563
at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/WebClient.cs:972
at System.Net.WebClient.DownloadDataCore (System.Uri address, System.Object userToken) [0x0000a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/WebClient.cs:271

当我尝试从非 SSL 网站下载字符串时,一切正常,加载字符串没有任何问题。

网站证书完全有效,在模拟器和OSX中都没有被Safari拒绝。

我正在模拟器上运行应用程序。

如果您能帮助我解决问题,我将不胜感激。

我用来从服务器获取字符串的代码是:

System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
WebClient wc = new WebClient ();
wc.CachePolicy = new System.Net.Cache.RequestCachePolicy (System.Net.Cache.RequestCacheLevel.NoCacheNoStore );
result = wc.DownloadString (Url);

问候

最佳答案

在使用 mono 访问 SSL 站点之前,您必须运行 mozroots --import --sync 以导入 mozilla 可信证书列表。

此外,还有 mono security FAQ这有助于解决 SSL 问题。

关于ios - Xamarin - 尝试从 SSL 网站 (WebClient) 下载字符串时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26943813/

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