我正试图请求一个http域,尽管
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>my-private-domain.kubernetes.intranet%2f:9090</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>在我的应用程序目标info.plist中,XCode 12.5.1使我不断地显示错误
Task <C5F9EA01-9790-43ED-89B0-EE07341B4D84>.<4> finished with error [-1022] Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.我需要在更新到12.5.1之后执行这个请求,并且尝试了清洁构建文件夹和删除-重新安装应用程序。有人知道这是不是政策上的改变吗?(也许现在只有HTTPS被允许,即使在非生产目标中也是如此。)我在这里找到的答案只引用了NSAllowsArbitraryLoads、NSExceptionDomains、NSExceptionMinimumTLSVersion/NSTemporaryExceptionMinimumTLSVersion和NSThirdPartyExceptionRequiresForwardSecrecy。还有别的事吗?
发布于 2021-06-28 16:41:46
因为您的info.plist包含NSAllowsArbitraryLoadsInWebContent键,所以NSAllowsArbitraryLoads被忽略,并被视为false。因此,删除NSAllowsArbitraryLoadsInWebContent应该允许所有任意负载。
来自苹果文档的相关部分
在iOS 10及更高版本和macOS 10.12及更高版本中,如果应用程序的Information文件中存在以下任何键,则忽略NSAllowsArbitraryLoads键的值,并忽略默认值NO used:
https://stackoverflow.com/questions/68165100
复制相似问题