NSURLSession/NSURLConnection HTTP 加载失败 (kCFStreamErrorDomainSSL, -9813) 在 iOS 9 与 Xcode 7.1
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39232510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813) in iOS 9 with Xcode 7.1
提问by SAYAN NANDY
I am using iOS 9 as target & using Xcode 7.1, tried everything as my level best for all the solutions of ATS but didn't work. Below is the following error description coming at console. If any suggestion comes I will be obliged.
我使用 iOS 9 作为目标并使用 Xcode 7.1,尝试了所有 ATS 解决方案的最佳水平,但没有奏效。以下是来自控制台的以下错误描述。如果有任何建议,我将有义务。
Some of the key things here are -
这里的一些关键是——
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
Error excluding Main.db from backup Error Domain=NSCocoaErrorDomain Code=4 "The file “Main.db” doesn't exist." UserInfo={NSURL=file:///Users/Raj/Library/Developer/CoreSimulator/Devices/BC3A0589-3B9A-4AFD-8F2A-B1C92FA341DD/data/Containers/Data/Application/70B3043A-8553-41E5-A147-8508D08BF3E6/Documents/Main.db, NSFilePath=/Users/Raj/Library/Developer/CoreSimulator/Devices/BC3A0589-3B9A-4AFD-8F2A-B1C92FA341DD/data/Containers/Data/Application/70B3043A-8553-41E5-A147-8508D08BF3E6/Documents/Main.db, NSUnderlyingError=0x798465c0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
2016-08-30 21:09:10.867 GFIM[80653:484899] SFOAuthCredentials:revokeRefreshToken: refresh token revoked. Cleared identityUrl, instanceUrl, issuedAt fields
2016-08-30 21:09:10.871 GFIM[80653:484899] INFO|0|SFPasscodeManager|Resetting passcode upon logout.
SFOAuthCredentials:revokeRefreshToken: refresh token revoked. Cleared identityUrl, instanceUrl, issuedAt fields
These are the things might be the cause of issue.
这些事情可能是问题的原因。
2016-08-30 21:09:19.095 GFIM[80653:484899] SFOAuthCoordinator:webViewDidStartLoad: host=test.salesforce.com : path=/
2016-08-30 21:09:19.863 GFIM[80653:484962] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-08-30 21:09:19.983 GFIM[80653:484962] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-08-30 21:09:20.016 GFIM[80653:484962] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-08-30 21:09:20.054 GFIM[80653:484962] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-08-30 21:09:20.194 GFIM[80653:484962] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-08-30 21:09:20.956 GFIM[80653:484962] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9813)
2016-08-30 21:09:38.285 GFIM[80653:484899] SFOAuthCoordinator:webView:shouldStartLoadWithRequest: (navType=1): host=test.salesforce.com : path=/
2016-08-30 21:09:38.311 GFIM[80653:484899] SFOAuthCoordinator:webViewDidStartLoad: host=test.salesforce.com : path=/
2016-08-30 21:09:38.834 GFIM[80653:484899] SFOAuthCoordinator:webView:shouldStartLoadWithRequest: (navType=1): host=5-prod--stg.cs30.my.salesforce.com : path=/secur/frontdoor.jsp
回答by BoxAndBirdie
If you try to make HTTP requests with ATS enabled (using NSURLSession or libraries like AFNetworking), you'll see errors like this.
如果您尝试在启用 ATS 的情况下发出 HTTP 请求(使用 NSURLSession 或 AFNetworking 等库),您将看到类似这样的错误。
Here's how to disable ATS entirely. Open Info.plist, and add the following lines:
以下是完全禁用 ATS 的方法。打开 Info.plist,并添加以下几行:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Your info.plist file should look like this
你的 info.plist 文件应该是这样的
See this post: https://stackoverflow.com/a/31077483/6763322
回答by Aakash Gupta
From iOS 9 Onwards Apple Enforce To make HTTP Request with Specific Host for Security Purpose. //Also works on iOS 10 with Swift 3
从 iOS 9 开始,Apple 出于安全目的强制使用特定主机发出 HTTP 请求。//也适用于带有 Swift 3 的 iOS 10
For that, you need to Add NSAppTransportSecurity
Dictionary into your .plist
the file of Project. Then your plist
will look something like this as follows.
为此,您需要将NSAppTransportSecurity
字典添加到您.plist
的项目文件中。然后你的plist
将如下所示。
Here NSAllowArbitraryLoads
basically means Connect to anything (this is probably BAD). Instead of this you can add a particular Host to be Connect.
这里NSAllowArbitraryLoads
基本上意味着连接到任何东西(这可能很糟糕)。取而代之的是,您可以添加一个特定的主机来连接。
回答by Sateesh Pasala
I just ran it in the device instead of simulator.It started working
我只是在设备而不是模拟器中运行它。它开始工作