我正在使用Amazon S3存储桶来保存图像,它在Xcode 6中工作正常但在升级到Xcode 7之后,应用程序没有显示图像。但是当我启用NSAppTransportSecurity
安全性并且它正常工作时。
如果没有应用程序传输安全性,我怎样才能让它工作?
答案 0 :(得分:0)
您需要为托管图片的服务器添加例外,或者允许所有任意加载到您应用的plist文件。 iOS 9及更高版本需要NSAppTransportSecurity
。
例外:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>download.yourServer.com.s3.amazonaws.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>
允许所有连接:
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>