2015-09-21 18 views
6

Chúng tôi đã gặp lỗi bảo mật Giao thông vận tải ứng dụng trong trình mô phỏng (Xcode 7 chạy trên OSX 10.10.5). Chúng tôi đã triển khai các nguyên tắc FB cho iOS9.Yêu cầu mạng bảo mật FBSDK không thành công iOS9

Biểu đồ FB api được gọi là dựa trên SDK v.3.24.

Chúng tôi đã thêm SDK Facebook, được biên dịch thành công bằng Bit, sau khi chèn ngoại lệ bảo mật ứng dụng được yêu cầu vào tệp info.plist ứng dụng.

Lỗi trông giống như tài liệu Facebook thiếu cấu hình thông tin ATS.plist, i. E .:

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) 
2015-09-21 15:25:20.862 flirtop[41983:2110078] FBSDKLog: WARNING: FBSDK secure network request failed. Please verify you have configured your app for Application Transport Security compatibility described at https://developers.facebook.com/docs/ios/ios9 
2015-09-21 15:25:21.131 flirtop[41983:2110592] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) 
2015-09-21 15:25:21.132 flirtop[41983:2110078] FBSDKLog: WARNING: FBSDK secure network request failed. Please verify you have configured your app for Application Transport Security compatibility described at https://developers.facebook.com/docs/ios/ios9 
2015-09-21 15:25:21.135 flirtop[41983:2110078] Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSURLErrorFailingURLPeerTrustErrorKey=, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFStreamErrorDomainKey=3, _kCFStreamErrorCodeKey=-9802, NSErrorPeerCertificateChainKey={type = immutable, count = 2, values = (
    0 : 
    1 : 
)}, NSUnderlyingError=0x7fec5d300b40 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://graph.facebook.com/v2.4, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, kCFStreamPropertySSLPeerCertificates={type = immutable, count = 2, values = (
    0 : 
    1 : 
)}, _kCFStreamPropertySSLClientCertificateState=0, kCFStreamPropertySSLPeerTrust=, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., _kCFStreamErrorDomainKey=3, NSErrorFailingURLKey=https://graph.facebook.com/v2.4, _kCFStreamErrorCodeKey=-9802}}, NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., --- SNIP --

plist của chúng tôi, với Id App bỏ qua, là sau

<?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> 
+0

Vì bạn đã có 'facebook.com' và bao gồm các tên miền phụ' on', bạn đã thử chỉ cần xóa 'graph.facebook.com' để xem điều gì sẽ xảy ra? – Rog

+0

Vâng, đó không phải là vấn đề. –

Trả lời

3

Giải Quyết. Thông tin.plist được sao chép vào Gói ứng dụng không phải là gói phù hợp. Tác phẩm này không có mục nhập graph.facebook.com, điều này không cần thiết.

Nó trở nên rõ ràng khi tôi thử sử dụng Đăng nhập Facebook và nó đã phàn nàn rằng url fbauth2 không có trong tệp info.plist.

Ngẫu nhiên, phần kết thúc chính xác của Info.plist là như sau, bao gồm thiết lập SDK hoàn chỉnh chính xác của Facebook. NSExceptionRequiresForwardSecrecy = False đủ để FB đồ thị api hoạt động.

Vì máy chủ FB không thuộc quyền kiểm soát của tôi, có lẽ tôi nên sử dụng NSThirdPartyException, tuy nhiên các thiết lập sau hoạt động.

-- SNIP -- 
<key>UIMainStoryboardFile</key> 
    <string>Main</string> 
    <key>UIRequiredDeviceCapabilities</key> 
    <array> 
     <string>armv7</string> 
    </array> 
    <key>UIStatusBarTintParameters</key> 
    <dict> 
     <key>UINavigationBar</key> 
     <dict> 
      <key>Style</key> 
      <string>UIBarStyleDefault</string> 
      <key>Translucent</key> 
      <false/> 
     </dict> 
    </dict> 
    <key>UISupportedInterfaceOrientations</key> 
    <array> 
     <string>UIInterfaceOrientationPortrait</string> 
     <string>UIInterfaceOrientationLandscapeLeft</string> 
     <string>UIInterfaceOrientationLandscapeRight</string> 
     <string>UIInterfaceOrientationPortraitUpsideDown</string> 
    </array> 
    <key>UISupportedInterfaceOrientations~ipad</key> 
    <array> 
     <string>UIInterfaceOrientationPortrait</string> 
     <string>UIInterfaceOrientationPortraitUpsideDown</string> 
     <string>UIInterfaceOrientationLandscapeLeft</string> 
     <string>UIInterfaceOrientationLandscapeRight</string> 
    </array> 
    <key>NSAppTransportSecurity</key> 
    <dict> 
     <key>NSExceptionDomains</key> 
     <dict> 
      <key>facebook.com</key> 
      <dict> 
       <key>NSIncludesSubdomains</key> 
       <true/> 
       <key>NSExceptionRequiresForwardSecrecy</key> 
       <false/> 
      </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> 
+0

Tôi có tệp plist bao gồm fbauth2; ứng dụng đăng nhập và đăng xuất chính xác; tuy nhiên tôi vẫn nhận được lỗi 'sau: [4102: 149576] -canOpenURL: không thành công cho URL:" fbauth2:/"- error:" (null) "' Bất kỳ ý tưởng nào tại sao? – oyalhi

+0

Đó có thể là một vấn đề hoàn toàn không liên quan. Trong trường hợp của tôi, tôi đã nhận được một lỗi ("Lỗi SSL đã xảy ra và kết nối an toàn với máy chủ không thể được thực hiện."), Không phải là lỗi null. Sau khi điều tra rằng vấn đề không phải là về một số vấn đề phân bổ, nếu bạn vẫn gặp sự cố, bạn nên ghi lại các đoạn của mình và mở một câu hỏi khác. –

9

Thêm phần này vào tập tin Info.plist của bạn và các lỗi sẽ biến mất. Nếu bạn không hiểu mã XML, hãy xem ảnh chụp màn hình bên dưới.

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSExceptionDomains</key> 
    <dict> 
     <key>facebook.com</key> 
     <dict> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
      <false/> 
     </dict> 
     <key>fbcdn.net</key> 
     <dict> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
      <false/> 
     </dict> 
     <key>akamaihd.net</key> 
     <dict> 
      <key>NSIncludesSubdomains</key> 
      <true/> 
      <key>NSThirdPartyExceptionRequiresForwardSecrecy</key> 
      <false/> 
     </dict> 
    </dict> 
</dict> 

Ảnh chụp màn hình từ Xcode có thể giúp bạn tốt hơn so với XML tinh khiết: Here is a screenshot from Xcode that might help you better than the pure XML below.

+0

Cảm ơn, chàng trai. Nó nhanh chóng. – Felipe

0

tùy chọn khác là để “Cho phép tải Arbitrary”, bằng cách thiết lập NSAllowsArbitraryLoads chìa khóa để YES:

enter image description here

An optional Boolean value that, when set to YES, disables App Transport Security (ATS) for any domains for which you do not reenable ATS by using an exception domain dictionary.

Thông tin thêm here>>

Các vấn đề liên quan