2015-09-21 9 views
6

Abbiamo riscontrato errori di sicurezza del trasporto app nel simulatore (Xcode 7 in esecuzione su OSX 10.10.5). Abbiamo implementato le linee guida FB per iOS9.Richiesta rete protetta FBSDK non riuscita iOS9

L'API del grafico FB richiamata era quella basata su SDK v.3.24.

Abbiamo aggiunto l'SDK di Facebook, compilato con successo con Bit, dopo aver inserito le eccezioni necessarie per la sicurezza del trasporto di app nel file info.plist dell'app.

Gli errori erano simili a quelli della documentazione di Facebook in mancanza di ATS info.plist configuration, 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 --

nostro plist, con App Id omesso, è stato il seguente

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

Poiché hai già 'facebook.com' e include i sottodomini' on', hai provato semplicemente a rimuovere 'graph.facebook.com' per vedere cosa succede? – Rog

+0

Sì, non era questo il problema. –

risposta

3

risolto. L'info.plist che è stato copiato nel pacchetto App non era quello giusto. Questo funziona senza la voce graph.facebook.com, che non è necessaria.

È diventato evidente quando ho provato a utilizzare Facebook Login e si lamentava che l'URL fbauth2 non era presente nel file info.plist.

Per inciso, la parte finale corretta di Info.plist è la seguente, che include la corretta installazione completa di Facebook SDK. NSExceptionRequiresForwardSecrecy = False è sufficiente per far funzionare l'api del grafico FB.

Poiché i server FB non sono sotto il mio controllo, probabilmente dovrei usare NSThirdPartyException, tuttavia la seguente installazione funziona.

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

Ho il file plist incluso fbauth2; l'app effettua correttamente il login e il logout; tuttavia ottengo ancora il seguente errore ': [4102: 149576] -canOpenURL: failed for URL:" fbauth2:/"- error:" (null) "' Qualche idea sul perché? – oyalhi

+0

Questo è probabilmente un problema totalmente non correlato. Nel mio caso ho ricevuto un errore ("Si è verificato un errore SSL e non è possibile stabilire una connessione sicura con il server."), Non un errore nullo. Dopo aver verificato che il problema non riguarda un problema di allocazione, se si verificano ancora problemi, è necessario documentare i passaggi e aprire un'altra domanda. –

9

Aggiungi questo al vostro file Info.plist e gli errori andranno via. Se non capisci il codice XML, guarda lo screenshot qui sotto.

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

Screenshot Xcode che potrebbe aiutare a meglio del puro XML: Here is a screenshot from Xcode that might help you better than the pure XML below.

+0

Grazie, ragazzo. Ha fatto in fretta. – Felipe

0

Altra opzione è quella di “Consenti carichi arbitrari”, impostando NSAllowsArbitraryLoads chiave per 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.

Ulteriori informazioni here>>