在属性 NSAppTransportSecurity 下的 info.plist 中,我添加了一组与我的应用程序通信的域。但由于某些原因,我的设置仅适用于某些添加的域,不适用于所有域,但我不知道为什么。对于任何想法我都会非常有帮助。提前致谢。
例如,现在它适用于域 googleapis.com,但不适用于 imeteo.sk、imeteo.cz 或任何子域 ( http://m.imeteo.cz )
这是我的 info.plist 的片段
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowExceptionDomains</key>
<dict>
<key>imeteo.cz</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>imeteo.sk</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
<key>googleapis.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
尝试在 webview 中加载一些域或子域后,我得到了:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
最佳答案
尝试将 NSExceptionAllowsInsecureHTTPLoads 和 NSExceptionMinimumTLSVersion 替换为 NSTemporaryExceptionAllowsInsecureHTTPLoads 和 NSTemporaryExceptionMinimumTLSVersion,如下所示:
http://www.neglectedpotential.com/2015/06/working-with-apples-application-transport-security/
此外,我使用 NSExceptionDomains 而不是 NSAllowExceptionDomains。
关于objective-c - 我在 info.plist 中的 NSAppTransportSecurity 设置不适用于所有定义的域和子域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33919039/