试图在iOS9上运行我现有的应用程序,但在使用时却失败了AFURLSessionManager
。
__block NSURLSessionDataTask *task = [self.sessionManager dataTaskWithRequest:request completionHandler:^(NSURLResponse * __unused response, id responseObject, NSError *error) {
if (error) {
} else {
}
}];
[task resume];
我收到以下错误:
Error Domain=NSURLErrorDomain Code=-999 "cancelled.
还获得以下日志:
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9824
CFNetwork SSLHandshake failed (-9824)
更新:我为解决方案添加了多个更新:NSURLSession / NSURLConnection在iOS 9上的HTTP加载失败
找到的解决方案:
在iOS9中,ATS会在网络通话期间实施最佳做法,包括使用HTTPS。
ATS可以防止意外泄露,提供安全的默认行为,并且易于采用。无论您是创建新应用还是更新现有应用,都应尽快采用ATS。如果要开发新的应用程序,则应专门使用HTTPS。如果您已有应用程序,则应立即使用HTTPS,并制定一个计划,以尽快迁移其余应用程序。
在beta 1中,当前无法在info.plist中定义它。解决方案是手动添加:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Update1:这是一个临时解决方法,直到您准备采用iOS9 ATS支持。
Update2:有关更多详细信息,请参阅以下链接:http : //ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/
Update3:如果您尝试连接到仅具有TLS 1.0的主机(YOURHOST.COM)
将它们添加到您应用的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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句