尝试在 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)
Update:我已向我的解决方案添加了多个更新:NSURLSession/NSURLConnection HTTP 加载在 iOS 9 上失败 https://stackoverflow.com/questions/30739473/nsurlsession-nsurlconnection-http-load-failed-on-ios-9/30748166#30748166
找到解决方案:
在 iOS9 中,ATS 在网络调用期间强制实施最佳实践,包括使用 HTTPS。
来自苹果文档: https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html
ATS 可防止意外泄露,提供安全的默认行为,并且易于采用。无论您是创建新应用程序还是更新现有应用程序,您都应该尽快采用 ATS。如果您正在开发新应用程序,则应仅使用 HTTPS。如果您有现有应用程序,则应立即尽可能多地使用 HTTPS,并尽快制定迁移应用程序其余部分的计划。
在 beta 1 中,目前无法在 info.plist 中定义它。解决办法是手动添加:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Update1: 这是一个临时解决方法,直到您准备好采用 iOS9 ATS 支持为止。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)