2015-07-23 20 views
5

Sto usando un UIWebView e non riesco a caricare Facebook. Devo dire che sto usando Xcode 7 Beta 2 e iOS 9.0 beta 4.Errore caricamento web in UIWebView

Questo è l'errore:

Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." 
+0

rendere il collegamento utilizza https o rivedere WWDC2015 "Sicurezza e app" per imparare come creare eccezioni. Vedi anche http://stackoverflow.com/questions/31065204/ios-9-are-webviews-exempt-from-the-app-transport-security-exceptions-ats – CSmith

+0

cosa c'entra questo con Xcode? –

risposta

8

Così, risponderò alla mia domanda. Come ha risposto CSmith, Apple vuole che usiamo App Transport Security (ATS). Ma ancora, poiché ci sono molte persone non pronte, mostrerò il modo per evitarlo. Nel vostro info.plist aggiungere la prossima cosa:

<key>NSAppTransportSecurity</key> 
<dict> 
    <!--Include to allow all connections (DANGER)--> 
    <key>NSAllowsArbitraryLoads</key> 
    <true/> 
</dict> 

correlati: iOS 9 ... Are WebView(s) exempt from the App Transport Security Exceptions (ATS) rules that block insecure HTTP hosts?

1

in iOS 9 (e OS X 10.11) Apps non dovrebbe fare richieste HTTP non protetti in modo che siano disabilitati di default. Inoltre dovresti usare TLS 1.2 con segretezza in avanti. Le firme dei certificati RC4 e SHA-1 sono disabilitate e le chiavi per RSA dovrebbero essere lunghe almeno 2048 bit (256 bit per EC).

Se si desidera utilizzare https http o meno sicuro, è possibile definire eccezioni nel file info.plist dell'app.

<key>NSAppTransportSecurity</key> 
<dict> 
    <key>NSAllowsArbitraryLoads</key> 
    <true/> 
    <key>NSExceptionDomains</key> 
    <dict> 
    <key>yourserver.com</key> 
    <dict> 
     <!--Include to allow subdomains--> 
     <key>NSIncludesSubdomains</key> 
     <true/> 
     <!--Include to allow HTTP requests--> 
     <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> 
     <true/> 
     <!--Include to specify minimum TLS version--> 
     <key>NSTemporaryExceptionMinimumTLSVersion</key> 
     <string>TLSv1.1</string> 
    </dict> 
    </dict> 
</dict>