根据以下错误消息,我需要在info.plist中设置什么来启用HTTP模式?
传输安全性已阻止明文HTTP(HTTP://)资源因为它是不安全的。可以通过以下方式配置临时异常应用程序的Info.plist文件。
假设我的域名是example.com。
根据以下错误消息,我需要在info.plist中设置什么来启用HTTP模式?
传输安全性已阻止明文HTTP(HTTP://)资源因为它是不安全的。可以通过以下方式配置临时异常应用程序的Info.plist文件。
假设我的域名是example.com。
当前回答
**终于!!!已解决的应用程序传输安全**
1. Follow the follow the screen shot. Do it in Targets info Section.
其他回答
这是在iOS 9 GM种子上进行测试和工作的-这是允许特定域使用HTTP而不是HTTPS的配置:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key> <!--Include your domain at this line -->
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
NSAllowsArbitraryLoads必须为false,因为它不允许所有不安全的连接,但例外列表允许连接到一些没有HTTPS的域。
这里是直观的:
Use:
在类型为Dictionary的plist文件中添加新项NSAppTransportSecurity,然后在类型为Boolean的字典中添加子项NSAllowsArbitraryLoads,并设置bool值YES。这对我有用。
转到您的Info.plist
右键单击空白区域,然后单击“添加行”将密钥名称写为NSAppTransportSecurity,在其下选择例外域,将新项目添加到此写下需要访问的域名将域类型从字符串更改为字典,添加新项NSTemporaryExceptionAllowsInsecureHTTPLoads,这将是一个具有真值的布尔值。
2015-09-25(2015-09-18 Xcode更新后):
我用了一种非懒惰的方法,但没有奏效。以下是我的尝试。
第一
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>www.xxx.yyy.zzz</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
其次,
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>www.xxx.yyy.zzz</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
最后,我使用了懒惰的方法:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
这可能有点不安全,但我找不到其他解决方案。