【问题标题】:Error loading web in UIWebView在 UIWebView 中加载网页时出错
【发布时间】:2015-10-14 01:31:05
【问题描述】:
我正在使用 UIWebView,但无法加载 facebook。我不得不说我使用的是 xcode 7 beta 2 和 iOS 9.0 beta 4。
这是错误:
Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
【问题讨论】:
标签:
ios
objective-c
xcode
app-transport-security
【解决方案2】:
在 iOS 9(和 OS X 10.11)中,应用程序不应发出不受保护的 HTTP 请求,因此默认情况下它们被禁用。此外,您应该使用具有前向保密性的 TLS 1.2。 RC4 和 SHA-1 证书签名被禁用,RSA 的密钥至少应为 2048 位(EC 为 256 位)。
如果您真的想使用 http 或安全性较低的 https,您可以在应用的 info.plist 文件中定义例外。
<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>