Iphone 当使用https时,它与Android手机配合得很好,但在i-phone上收到错误消息:“http;错误域=NSURLErrorDomain代码=-1200“;
我的visual studio Xamarin.Form应用程序在Android手机上运行良好,但在iPhone或iPhone模拟器上失败,原因如下:Iphone 当使用https时,它与Android手机配合得很好,但在i-phone上收到错误消息:“http;错误域=NSURLErrorDomain代码=-1200“;,iphone,visual-studio,xamarin.forms,https,xamarin.ios,Iphone,Visual Studio,Xamarin.forms,Https,Xamarin.ios,我的visual studio Xamarin.Form应用程序在Android手机上运行良好,但在iPhone或iPhone模拟器上失败,原因如下: var content = await _client.GetStringAsync(RI_Url); // RI_Ur1 is "https://xxxxxxx" 当我在Safari、Chrome和Edge中放置RI_Url时,它可以显示结果 如果RI\u Uri=”它就工作了http://xxxxxxx“ 我试图将以下内容放入info
var content = await _client.GetStringAsync(RI_Url); // RI_Ur1 is "https://xxxxxxx"
当我在Safari、Chrome和Edge中放置RI_Url
时,它可以显示结果
如果RI\u Uri=”它就工作了http://xxxxxxx“
我试图将以下内容放入info.plist,但它不起作用
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads
有人能帮忙解决这个问题吗
谢谢
错误消息是:
{System.Net.Http.HttpRequestException: An SSL error has occurred and a secure connection to the server cannot be made. --->
Foundation.NSErrorException: Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made."
UserInfo={NSErrorFailingURLStringKey=https://xxxxxxxxxxxxxxxxxx,
NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3,
_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <60343732-0A70-45A6-A4BB-263867134C53>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <60343732-0A70-45A6-A4BB-263867134C53>.<1>"
), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made.,
NSErrorFailingURLKey=https://xxxxxxxxxxxxxxxxxxx,
NSUnderlyingError=0x6000024cafd0 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)"
UserInfo={_kCFStreamPropertySSLClientCertificateState=0, _kCFNetworkCFStreamSSLErrorOriginalValue=-9836, _kCFStreamErrorDomainKey=3,
_kCFStreamErrorCodeKey=-9836}}, _kCFStreamErrorCodeKey=-9836}
--- End of inner exception stack trace ---
at System.Net.Http.NSUrlSessionHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
[0x001d4] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/Foundation/NSUrlSessionHandler.cs:437
at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption,
System.Threading.CancellationToken cancellationToken) [0x0009e]
in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:281
at System.Net.Http.HttpClient.GetStringAsync (System.String requestUri) [0x00033]
in /Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:328
at xxxxxxxxx.OnGetList () [0x00039] in C:\xxxxxxx\xxxxxxxxPage.xaml.cs:41 }
{System.Net.Http.HttpRequestException:发生SSL错误,无法与服务器建立安全连接。-->
NoSerrExebug:错误域= NSurLelRoRe域代码= -1200“SSL错误已经发生,无法与服务器建立安全连接。”
UserInfo={NSErrorFailingURLStringKey=https://xxxxxxxxxxxxxxxxxx,
NSLocalizedRecoverysSuggestion=是否仍要连接到服务器?,kCFStreamErrorDomainKey=3,
_NSURLERRORFAILINGURLSessiontaskerrokery=LocalDataTask.,\u NSURLErrorRelatedURLSessionTaskErrorKey=(
“LocalDataTask。”
),NSLocalizedDescription=发生SSL错误,无法与服务器建立安全连接。,
N错误失效键=https://xxxxxxxxxxxxxxxxxxx,
NSUnderlyingError=0x6000024cafd0{Error Domain=KCferrordomaincfn网络代码=-1200“(空)”
UserInfo={kCFStreamPropertySSLClientCertificateState=0,\KCFnetworkCFstreamsSrorOriginalValue=-9836,\kCFStreamErrorDomainKey=3,
_kCFStreamErrorCodeKey=-9836},kCFStreamErrorCodeKey=-9836}
---内部异常堆栈跟踪的结束---
位于System.Net.Http.NSUrlSessionHandler.SendAsync(System.Net.Http.HttpRequestMessage请求,System.Threading.CancellationToken CancellationToken)
[0x001d4]in/Library/Frameworks/Xamarin.iOS.framework/Versions/13.2.0.42/src/Xamarin.iOS/Foundation/NSUrlSessionHandler.cs:437
在System.Net.Http.HttpClient.SendAsyncWorker(System.Net.Http.HttpRequestMessage请求,System.Net.Http.HttpCompletionOption completionOption,
System.Threading.CancellationToken CancellationToken)[0x0009e]
在/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:281中
位于System.Net.Http.HttpClient.GetStringAsync(System.String requestUri)[0x00033]
在/Users/builder/jenkins/workspace/xamarin-macios/xamarin-macios/external/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:328中
在C:\xxxxxxx\xxxxxxx page.xaml.cs:41}中的xxxxxxxxx.OnGetList()[0x00039]
试试这个:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>yoururl</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads
NSExceptionDomains
yoururl
n包括多个域
N异常低安全Http负载
我在info.plist的末尾添加了您的代码,但仍然不起作用。代码添加到最后一行的正上方。我想知道我是否添加了错误的代码。它可能会加载到浏览器中,但该站点是否确实存在证书错误?您可以加载另一个已知良好的https吗?由于iOS 9,iOS将只允许您的应用程序与默认情况下实现最佳实践安全性的服务器通信。必须在Info.plist中设置值以启用与不安全服务器的通信。检查