Tried to run my existing app on iOS9 but getting failure while using AFURLSessionManager
.
试图在iOS9上运行我现有的应用程序,但在使用AFURLSessionManager时失败。
__block NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
if (error) {
} else {
}
}];
[task resume];
I get the following error:
我得到了以下错误:
Error Domain=NSURLErrorDomain Code=-999 "cancelled.
Also getting following logs:
还得到以下日志:
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824
CFNetwork SSLHandshake failed (-9824)
Update: I have added multiple updates to my solution: NSURLSession/NSURLConnection HTTP load failed on iOS 9
更新:我已经为我的解决方案添加了多个更新:NSURLSession/NSURLConnection HTTP负载在ios9上失败了。
12 个解决方案
#1
236
Found solution:
找到了解决方案:
In iOS9, ATS enforces best practices during network calls, including the use of HTTPS.
在iOS9中,ATS在网络调用期间执行最佳实践,包括使用HTTPS。
从苹果公司文档:
ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one. If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible.
ATS防止意外披露,提供安全的默认行为,并且易于采用。无论你是在创建一个新的应用程序,还是在更新现有的应用程序,你都应该尽快采用ATS。如果你正在开发一个新的应用程序,你应该只使用HTTPS。如果你有一个现有的应用程序,你应该尽可能多地使用HTTPS,并创建一个计划,让你的应用程序尽快迁移。
In beta 1, currently there is no way to define this in info.plist. Solution is to add it manually:
在beta 1中,目前没有办法在info.plist中定义这个。解决方案是手动添加:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Update1: This is a temporary workaround until you're ready to adopt iOS9 ATS support.
Update1:这是一个临时工作,直到您准备采用iOS9 ATS支持。
Update2: For more details please refer following link: http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
Update2:更多细节请参考下面的链接:http://ste.vn/2015/06/10/configurationapp-transportsecurityios-9-osx -10-11/。
Update3: If you are trying to connect to a host (YOURHOST.COM) that only has TLS 1.0
Update3:如果您试图连接到一个只有TLS 1.0的主机(YOURHOST.COM)。
Add these to your app's Info.plist
把这些添加到你的应用程序的Info.plist中。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>YOURHOST.COM</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>1.0</string>
<key>NSTemporaryExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
#2
51
How to deal with the SSL in iOS9,One solution is to do like:
如何处理在iOS9 SSL,像一个解决方案是:
As the Apple say :
就像苹果说的:
iOS 9 and OSX 10.11 require TLSv1.2 SSL for all hosts you plan to request data from unless you specify exception domains in your app's Info.plist file.
ios9和OSX 10.11要求所有的主机都使用TLSv1.2 SSL,除非你在应用程序的信息中指定异常域。plist文件。
The syntax for the Info.plist configuration looks like this:
信息的语法。plist配置如下所示:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
If your application (a third-party web browser, for instance) needs to connect to arbitrary hosts, you can configure it like this:
如果您的应用程序(例如第三方web浏览器)需要连接到任意主机,您可以这样配置它:
<key>NSAppTransportSecurity</key>
<dict>
<!--Connect to anything (this is probably BAD)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
If you're having to do this, it's probably best to update your servers to use TLSv1.2 and SSL, if they're not already doing so. This should be considered a temporary workaround.
如果您必须这样做,最好是更新您的服务器以使用TLSv1.2和SSL,如果它们还没有这样做的话。这应该被看作是一种临时的变通方法。
As of today, the prerelease documentation makes no mention of any of these configuration options in any specific way. Once it does, I'll update the answer to link to the relevant documentation.
到今天为止,预发布文档没有以任何特定的方式提到这些配置选项。一旦它完成了,我将更新答案以链接到相关的文档。
For more info ,go to iOS9AdaptationTips
想了解更多信息,请访问iOS9AdaptationTips。
#3
37
Apple's Technote on App Transport Security is very handy; it helped us find a more secure solution to our issue.
苹果在应用程序传输安全方面的技术说明非常方便;它帮助我们找到了一个更安全的解决方案。
Hopefully this will help someone else. We were having issues connecting to Amazon S3 URLs that appeared to be perfectly valid, TLSv12 HTTPS URLs. Turns out we had to disable NSExceptionRequiresForwardSecrecy
to enable another handful of ciphers that S3 uses.
希望这能帮助到其他人。我们在连接Amazon S3 url时遇到了一些问题,这些url看起来是完全有效的,TLSv12 HTTPS url。事实证明,我们必须禁用nsexceptionrequiresforwardsecret来启用S3使用的另一些密码。
In our Info.plist
:
在我们Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
#4
6
If you're having this problem with Amazon S3 as me, try to paste this on your info.plist as a direct child of your top level tag
如果您在Amazon S3中遇到了这个问题,请尝试将其粘贴到您的信息上。plist是*标签的直接子元素。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>amazonaws.com.cn</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
You can find more info at:
你可以找到更多的信息:
http://docs.aws.amazon.com/mobile/sdkforios/developerguide/ats.html#resolving-the-issue
http://docs.aws.amazon.com/mobile/sdkforios/developerguide/ats.html解决这一问题
#5
4
I found solution from here. And its working for me.
我从这里找到了解决方案。它为我工作。
Check this, it may help you.
检查一下,它可能会对你有帮助。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>myDomain.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
#6
#7
1
Update:
更新:
As of Xcode 7.1, you don't need to manually enter the NSAppTransportSecurity
Dictionary in the info.plist
.
在Xcode 7.1中,您不需要在info.plist中手动输入NSAppTransportSecurity字典。
It will now autocomplete for you, realize it's a dictionary, and then autocomplete the Allows Arbitrary
Loads as well. info.plist screenshot
现在它将自动完成,实现它是一个字典,然后自动完成允许任意的负载。信息。plist截图
#8
1
Solve NSURLConnection Http load failed bug Just Add following Dict in info.plist:
解决NSURLConnection Http加载失败的错误,只需要在info.plist中添加以下命令:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
#9
0
I have solved it with adding some key in info.plist. The steps I followed are:
我已经在info.plist中添加了一些键来解决它。我遵循的步骤如下:
I Opened my project's info.plist file
我打开了我的项目信息。plist文件
Added a Key called NSAppTransportSecurity as a Dictionary.
添加一个名为NSAppTransportSecurity的键作为字典。
Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image. enter image description here
添加一个名为nsallowsarbityload的子键作为布尔值,并将其值设为YES,如下图所示。在这里输入图像描述
Clean the Project and Now Everything is Running fine as like before.
清理项目,现在一切运行良好,就像以前一样。
Ref Link: https://*.com/a/32609970
参考链接:https://*.com/a/32609970
#10
0
This is what worked for me when I had this error:
当我有这个错误的时候,这就是我的工作:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
</dict>
</dict>
#11
0
You can try add this function in file RCTHTTPRequestHandler.m
您可以尝试在文件rcthttprequesthandlerm .m中添加这个函数。
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); }
-(void)URLSession:(NSURLSession *)会话didReceiveChallenge:completionHandler(NSURLAuthenticationChallenge *)挑战:(空白(^)(NSURLSessionAuthChallengeDisposition性格,NSURLCredential *凭据))completionHandler { completionHandler(NSURLSessionAuthChallengeUseCredential,[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);}
#12
0
In addition to the above mentioned answers ,recheck your url
除了上述的答案,重新检查你的网址。
#1
236
Found solution:
找到了解决方案:
In iOS9, ATS enforces best practices during network calls, including the use of HTTPS.
在iOS9中,ATS在网络调用期间执行最佳实践,包括使用HTTPS。
从苹果公司文档:
ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one. If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible.
ATS防止意外披露,提供安全的默认行为,并且易于采用。无论你是在创建一个新的应用程序,还是在更新现有的应用程序,你都应该尽快采用ATS。如果你正在开发一个新的应用程序,你应该只使用HTTPS。如果你有一个现有的应用程序,你应该尽可能多地使用HTTPS,并创建一个计划,让你的应用程序尽快迁移。
In beta 1, currently there is no way to define this in info.plist. Solution is to add it manually:
在beta 1中,目前没有办法在info.plist中定义这个。解决方案是手动添加:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Update1: This is a temporary workaround until you're ready to adopt iOS9 ATS support.
Update1:这是一个临时工作,直到您准备采用iOS9 ATS支持。
Update2: For more details please refer following link: http://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
Update2:更多细节请参考下面的链接:http://ste.vn/2015/06/10/configurationapp-transportsecurityios-9-osx -10-11/。
Update3: If you are trying to connect to a host (YOURHOST.COM) that only has TLS 1.0
Update3:如果您试图连接到一个只有TLS 1.0的主机(YOURHOST.COM)。
Add these to your app's Info.plist
把这些添加到你的应用程序的Info.plist中。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>YOURHOST.COM</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>1.0</string>
<key>NSTemporaryExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
#2
51
How to deal with the SSL in iOS9,One solution is to do like:
如何处理在iOS9 SSL,像一个解决方案是:
As the Apple say :
就像苹果说的:
iOS 9 and OSX 10.11 require TLSv1.2 SSL for all hosts you plan to request data from unless you specify exception domains in your app's Info.plist file.
ios9和OSX 10.11要求所有的主机都使用TLSv1.2 SSL,除非你在应用程序的信息中指定异常域。plist文件。
The syntax for the Info.plist configuration looks like this:
信息的语法。plist配置如下所示:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow insecure HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
If your application (a third-party web browser, for instance) needs to connect to arbitrary hosts, you can configure it like this:
如果您的应用程序(例如第三方web浏览器)需要连接到任意主机,您可以这样配置它:
<key>NSAppTransportSecurity</key>
<dict>
<!--Connect to anything (this is probably BAD)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
If you're having to do this, it's probably best to update your servers to use TLSv1.2 and SSL, if they're not already doing so. This should be considered a temporary workaround.
如果您必须这样做,最好是更新您的服务器以使用TLSv1.2和SSL,如果它们还没有这样做的话。这应该被看作是一种临时的变通方法。
As of today, the prerelease documentation makes no mention of any of these configuration options in any specific way. Once it does, I'll update the answer to link to the relevant documentation.
到今天为止,预发布文档没有以任何特定的方式提到这些配置选项。一旦它完成了,我将更新答案以链接到相关的文档。
For more info ,go to iOS9AdaptationTips
想了解更多信息,请访问iOS9AdaptationTips。
#3
37
Apple's Technote on App Transport Security is very handy; it helped us find a more secure solution to our issue.
苹果在应用程序传输安全方面的技术说明非常方便;它帮助我们找到了一个更安全的解决方案。
Hopefully this will help someone else. We were having issues connecting to Amazon S3 URLs that appeared to be perfectly valid, TLSv12 HTTPS URLs. Turns out we had to disable NSExceptionRequiresForwardSecrecy
to enable another handful of ciphers that S3 uses.
希望这能帮助到其他人。我们在连接Amazon S3 url时遇到了一些问题,这些url看起来是完全有效的,TLSv12 HTTPS url。事实证明,我们必须禁用nsexceptionrequiresforwardsecret来启用S3使用的另一些密码。
In our Info.plist
:
在我们Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
#4
6
If you're having this problem with Amazon S3 as me, try to paste this on your info.plist as a direct child of your top level tag
如果您在Amazon S3中遇到了这个问题,请尝试将其粘贴到您的信息上。plist是*标签的直接子元素。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>amazonaws.com</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>amazonaws.com.cn</key>
<dict>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
You can find more info at:
你可以找到更多的信息:
http://docs.aws.amazon.com/mobile/sdkforios/developerguide/ats.html#resolving-the-issue
http://docs.aws.amazon.com/mobile/sdkforios/developerguide/ats.html解决这一问题
#5
4
I found solution from here. And its working for me.
我从这里找到了解决方案。它为我工作。
Check this, it may help you.
检查一下,它可能会对你有帮助。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>myDomain.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
#6
3
Simply add the following fields in your .plist file
只需在.plist文件中添加以下字段。
Syntax looks like this:
语法是这样的:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
#7
1
Update:
更新:
As of Xcode 7.1, you don't need to manually enter the NSAppTransportSecurity
Dictionary in the info.plist
.
在Xcode 7.1中,您不需要在info.plist中手动输入NSAppTransportSecurity字典。
It will now autocomplete for you, realize it's a dictionary, and then autocomplete the Allows Arbitrary
Loads as well. info.plist screenshot
现在它将自动完成,实现它是一个字典,然后自动完成允许任意的负载。信息。plist截图
#8
1
Solve NSURLConnection Http load failed bug Just Add following Dict in info.plist:
解决NSURLConnection Http加载失败的错误,只需要在info.plist中添加以下命令:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
#9
0
I have solved it with adding some key in info.plist. The steps I followed are:
我已经在info.plist中添加了一些键来解决它。我遵循的步骤如下:
I Opened my project's info.plist file
我打开了我的项目信息。plist文件
Added a Key called NSAppTransportSecurity as a Dictionary.
添加一个名为NSAppTransportSecurity的键作为字典。
Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image. enter image description here
添加一个名为nsallowsarbityload的子键作为布尔值,并将其值设为YES,如下图所示。在这里输入图像描述
Clean the Project and Now Everything is Running fine as like before.
清理项目,现在一切运行良好,就像以前一样。
Ref Link: https://*.com/a/32609970
参考链接:https://*.com/a/32609970
#10
0
This is what worked for me when I had this error:
当我有这个错误的时候,这就是我的工作:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
</dict>
</dict>
#11
0
You can try add this function in file RCTHTTPRequestHandler.m
您可以尝试在文件rcthttprequesthandlerm .m中添加这个函数。
- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); }
-(void)URLSession:(NSURLSession *)会话didReceiveChallenge:completionHandler(NSURLAuthenticationChallenge *)挑战:(空白(^)(NSURLSessionAuthChallengeDisposition性格,NSURLCredential *凭据))completionHandler { completionHandler(NSURLSessionAuthChallengeUseCredential,[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);}
#12
0
In addition to the above mentioned answers ,recheck your url
除了上述的答案,重新检查你的网址。