2015-09-21 11 views
6

Otrzymaliśmy błędy App Transport Security w symulatorze (Xcode 7 działa na systemie OS X 10.10.5). Wdrożyliśmy wytyczne FB dla iOS9.Niepowodzenie żądania bezpiecznej sieci FBSDK iOS9

Wywołanie api wykresu FB było oparte na SDK v.3.24.

Dodaliśmy pakiet SDK do Facebooka, skompilowany z powodzeniem za pomocą Bit, po włożeniu wymaganych wyjątków App Transport Security do pliku App info.plist.

Błędy wyglądały tak jak te z dokumentacji Facebooka w braku konfiguracji ATS info.plist, . 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 --

nasz plist z App Id pominięty, był następujący

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

Ponieważ masz już stronę "facebook.com' i zawiera ona poddomeny' on', czy próbowałeś po prostu usunąć 'graph.facebook.com', aby zobaczyć, co się dzieje? – Rog

+0

Tak, to nie było problemem. –

Odpowiedz

3

rozwiązany. Plik info.plist, który został skopiowany do pakietu aplikacji, nie był właściwy. Działa to bez wpisu graph.facebook.com, który nie jest konieczny.

Stało się oczywiste, kiedy próbowałem używać Facebooka i skarżyłem się, że adres url fbauth2 nie był obecny w pliku info.plist.

Nawiasem mówiąc, poprawna część końcowa pliku Info.plist jest następująca, zawiera poprawną kompletną konfigurację pakietu Facebook SDK. NSExceptionRequiresForwardSecrecy = Fałsz wystarczy, aby api wykresu FB działało.

Ponieważ serwery FB nie są pod moją kontrolą, prawdopodobnie powinienem używać wyjątku NSThirdPartyException, jednak następująca konfiguracja działa.

-- 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

Mam plik plist, w tym fbauth2; aplikacja poprawnie się loguje i wylogowuje; jednak nadal otrzymuję następujący błąd: [4102: 149576] -canOpenURL: nie powiodło się dla adresu URL: "fbauth2: /" - error: "(null)" "Każdy pomysł, dlaczego? – oyalhi

+0

To prawdopodobnie całkowicie niezwiązany problem. W moim przypadku wystąpił błąd ("Wystąpił błąd SSL i nie można utworzyć bezpiecznego połączenia z serwerem."), A nie błąd o wartości null. Po zbadaniu, że problem nie dotyczy jakiegoś problemu z przydziałem, jeśli nadal masz problemy, powinieneś udokumentować swoje fragmenty i otworzyć kolejne pytanie. –

9

Dodaj do tego pliku Info.plist i błędy odejdzie. Jeśli nie rozumiesz kodu XML, zobacz zrzut ekranu poniżej.

<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> 

Zrzut ekranu z Xcode, które mogą Ci pomóc lepiej niż czysta XML: Here is a screenshot from Xcode that might help you better than the pure XML below.

+0

Dzięki, chłopcze. Zrobiłem to szybko. – Felipe

0

Inną opcją jest „Pozwól arbitralne ciężarów”, ustawiając NSAllowsArbitraryLoads kluczem do 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.

Więcej informacji here>>