【发布时间】:2015-12-18 07:53:02
【问题描述】:
我们在模拟器中遇到了 App Transport Security 错误(Xcode 7 在 OSX 10.10.5 上运行)。我们为 iOS9 实施了 FB 指南。
调用的FB graph api是基于SDK v.3.24的。
在将所需的应用程序传输安全异常插入应用程序 info.plist 文件后,我们添加了 Facebook SDK,使用 Bit 成功编译。
这些错误看起来像 Facebook 文档中缺少 ATS info.plist 配置, 一世。 e.:
NSURLSession/NSURLConnection HTTP 加载失败 (kCFStreamErrorDomainSSL, -9802)
2015-09-21 15:25:20.862 flirtop [41983:2110078] FBSDKLog:警告:FBSDK 安全网络请求失败。请验证您已为应用程序传输安全兼容性配置您的应用程序,如 https://developers.facebook.com/docs/ios/ios9 所述
2015-09-21 15:25:21.131 flirtop [41983:2110592] NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9802)
2015-09-21 15:25:21.132 flirtop [41983:2110078] FBSDKLog:警告:FBSDK 安全网络请求失败。请验证您已为应用程序传输安全兼容性配置您的应用程序,如 https://developers.facebook.com/docs/ios/ios9 所述
2015-09-21 15:25:21.135 flirtop[41983:2110078] 错误域=NSURLErrorDomain 代码=-1200 “发生 SSL 错误,无法与服务器建立安全连接。” UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=, NSLocalizedRecoverySuggestion=您是否仍要连接到服务器?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, NSErrorPeerCertificateChainKey={type = immutable, count = 2, values = (
0:
1:
)}, NSUnderlyingError=0x7fec5d300b40 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 “发生 SSL 错误,无法与服务器建立安全连接。” UserInfo={NSErrorFailingURLStringKey=https://graph.facebook.com/v2.4, NSLocalizedRecoverySuggestion=你还想连接到服务器吗?, _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, kCFStreamPropertySSLPeerCertificates={type = immutable, count = 2, values = (
0:
1:
)}, _kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=, NSLocalizedDescription=发生 SSL 错误,无法与服务器建立安全连接。, _kCFStreamErrorDomainKey=3, NSErrorFailingURLKey=https://graph.facebook.com/v2.4, _kCFStreamErrorCodeKey =-9802}}, NSLocalizedDescription=发生 SSL 错误,无法与服务器建立安全连接。, --- SNIP --
我们的 plist 省略了 App Id,如下所示
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.fwlab.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>OMITTED</string>
</array>
</dict>
</array>
<key>FacebookAppID</key>
<string>OMITTED</string>
<key>FacebookDisplayName</key>
<string>Flirtop</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>graph.facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>facebook.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>fbcdn.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>akamaihd.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
</dict>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fbapi20130214</string>
<string>fbapi20130410</string>
<string>fbapi20130702</string>
<string>fbapi20131010</string>
<string>fbapi20131219</string>
<string>fbapi20140410</string>
<string>fbapi20140116</string>
<string>fbapi20150313</string>
<string>fbapi20150629</string>
<string>fbauth</string>
<string>fbauth2</string>
<string>fb-messenger-api20140430</string>
<string>fb-messenger-platform-20150128</string>
<string>fb-messenger-platform-20150218</string>
<string>fb-messenger-platform-20150305</string>
</array>
</dict>
</plist>
【问题讨论】:
-
既然您已经拥有
facebook.com并包含子域on,您是否尝试过简单地删除graph.facebook.com看看会发生什么? -
是的,这不是问题。