因此,昨晚发布的新的iOS测试版SDK有“”,它鼓励开发人员使用https而不是http。原则上,这是一个很好的想法,我已经在我们的阶段/生产环境中使用了https。然而,当iOS应用程序连接到我在笔记本上运行的web服务时,我没有在本地开发环境中设置https。
从今天上午的情况来看,URL加载系统将决定使用https,即使您向它传递了一个http URL。有谁知道如何禁用这种行为--即使是针对特定的URL?
发布于 2015-06-09 12:57:33
有关详细信息,请参阅苹果的Info.plist reference (谢谢@gnasher729)。
您可以在Info.plist中添加特定域的异常:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>testdomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<false/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>每个例外域的所有键都是可选的。演讲者没有详细说明其中的任何一个键,但我认为它们都是相当明显的。
(资料来源:WWDC 2015 session 703, “Privacy and Your App”,30:18)
如果您的应用程序有很好的理由这样做,您也可以用一个键忽略所有应用程序传输安全限制:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>如果您的应用程序没有很好的理由,您可能面临被拒绝的风险:
将NSAllowsArbitraryLoads设置为true将允许其工作,但苹果非常清楚,他们打算拒绝使用此标志的应用程序,而没有具体的原因。我认为使用NSAllowsArbitraryLoads的主要原因是用户创建的内容(链接共享、自定义web浏览器等)。在这种情况下,Apple仍然希望您包含一些异常,这些异常会对您控制的URL强制使用ATS。 如果您确实需要访问TLS1.2中没有提供的特定URL,则需要为这些域编写特定的异常,而不是将NSAllowsArbitraryLoads设置为yes。您可以在NSURLSesssion WWDC会话中找到更多信息。 请在共享NSAllowsArbitraryLoads解决方案时小心。这不是苹果推荐的解决方案。
- kcharwood (谢谢@marco)
发布于 2015-06-10 08:54:51
作为公认的答案提供了所需的信息,以及更多关于使用和disabling App Transport Security one can find more on this的信息。
对于每个域异常,将它们添加到Info.plist中。
<key>NSAppTransportSecurity</key>
<dict>
<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>,但如果我不知道需要使用的所有不安全域怎么办?在Info.plist中使用以下键
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>For more detail you can get from this link.
https://stackoverflow.com/questions/30731785
复制相似问题