热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在iOS9中禁用应用内浏览器的ATS?-DisablingATSforanin-appbrowseriniOS9?

iOS9introducesAppTransportSecurity(ATS)toencouragetheuseofsecureconnections.iOS9引入了Ap

iOS 9 introduces App Transport Security (ATS) to encourage the use of secure connections.

iOS 9引入了App Transport Security(ATS)以鼓励使用安全连接。

This is great, but what if my app has a built in web browser that the user should be able to use to connect to any website? For example, the Facebook app allows stories to contain links to external websites. When the user taps such a link, rather than launching Safari, it launches an in-app browser.

这很棒,但是如果我的应用程序有一个内置的Web浏览器,用户应该可以使用它连接到任何网站怎么办?例如,Facebook应用程序允许故事包含指向外部网站的链接。当用户点击这样的链接,而不是启动Safari时,它会启动应用内浏览器。

How can I get this same behavior without enabling the global NSAllowArbitraryLoads flag?

如何在不启用全局NSAllowArbitraryLoads标志的情况下获得相同的行为?

I want all the benefits of enforcing https usage, but want to disable this check in my internal browser. In an ideal world, Apple would allow me to specify a property on my UIWebView to allow it to load insecure URLs, rather than it being all or nothing. There is no way I can whitelist every single domain, since I have no idea which URLs my users will load. I'm looking for a solution that is compatible with iOS 8.

我想要强制执行https使用的所有好处,但想要在我的内部浏览器中禁用此检查。在一个理想的世界中,Apple允许我在我的UIWebView上指定一个属性,以允许它加载不安全的URL,而不是全部或全部。我无法将每个域列入白名单,因为我不知道用户将加载哪些URL。我正在寻找与iOS 8兼容的解决方案。

2 个解决方案

#1


1  

In this case you will need to disable ATS generally, by setting NSAllowsArbitraryLoads to true. If you have specific URLs that you know can support HTTPS (such as your own servers or API servers that you use in the app outside of the UIWebView) then you can create an exception and set NSExceptionsAllowsInsecureHTTPLoads to false for those exceptions

在这种情况下,您需要通常将NSAllowsArbitraryLoads设置为true来禁用ATS。如果您具有可以支持HTTPS的特定URL(例如您在UIWebView之外的应用程序中使用的自己的服务器或API服务器),则可以创建异常并将NSExceptionsAllowsInsecureHTTPLoads设置为false以用于这些异常

#2


1  

Rather than enabling NSAllowsArbitraryLoads, a more secure solution is to conditionally use SFSafariViewController, which allows arbitrary loads.

而不是启用NSAllowsArbitraryLoads,更安全的解决方案是有条件地使用SFSafariViewController,它允许任意加载。

If the class exists, then present it, otherwise, present your own UIViewController (which contains a UIWebView).

如果该类存在,则呈现它,否则,呈现您自己的UIViewController(包含UIWebView)。

UIViewController *webBrowser;
if ([SFSafariViewController class] != nil) {
    webBrowser = [[SFSafariViewController alloc] initWithURL:url];
} else {
    webBrowser = [[ABCWebBrowserController alloc] initWithURL:url];
}

[self presentViewController:webBrowser animated:YES completion:nil];

推荐阅读
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • UNP 第9章:主机名与地址转换
    本章探讨了用于在主机名和数值地址之间进行转换的函数,如gethostbyname和gethostbyaddr。此外,还介绍了getservbyname和getservbyport函数,用于在服务器名和端口号之间进行转换。 ... [详细]
  • Explore how Matterverse is redefining the metaverse experience, creating immersive and meaningful virtual environments that foster genuine connections and economic opportunities. ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • DNN Community 和 Professional 版本的主要差异
    本文详细解析了 DotNetNuke (DNN) 的两种主要版本:Community 和 Professional。通过对比两者的功能和附加组件,帮助用户选择最适合其需求的版本。 ... [详细]
  • 动画队列的设计目的是为了确保一系列任务能够按照预定顺序执行,每个任务只有在其前一个任务完成后才开始。这些任务既可以是同步的,也可以是异步的。本文将探讨jQuery动画系统中的队列机制,并介绍如何使用队列来优化动画效果。 ... [详细]
  • 探索PWA H5 Web App优化之路(Service Worker与Lighthouse的应用)
    本文探讨了如何通过Service Worker和Lighthouse工具来优化PWA H5 Web App,旨在提升用户体验,包括提高加载速度、增强离线访问能力等方面。 ... [详细]
  • golang常用库:配置文件解析库/管理工具viper使用
    golang常用库:配置文件解析库管理工具-viper使用-一、viper简介viper配置管理解析库,是由大神SteveFrancia开发,他在google领导着golang的 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • ImmutableX Poised to Pioneer Web3 Gaming Revolution
    ImmutableX is set to spearhead the evolution of Web3 gaming, with its innovative technologies and strategic partnerships driving significant advancements in the industry. ... [详细]
  • 本文详细解析了Python中的os和sys模块,介绍了它们的功能、常用方法及其在实际编程中的应用。 ... [详细]
  • 本文详细介绍了macOS系统的核心组件,包括如何管理其安全特性——系统完整性保护(SIP),并探讨了不同版本的更新亮点。对于使用macOS系统的用户来说,了解这些信息有助于更好地管理和优化系统性能。 ... [详细]
  • 使用Vultr云服务器和Namesilo域名搭建个人网站
    本文详细介绍了如何通过Vultr云服务器和Namesilo域名搭建一个功能齐全的个人网站,包括购买、配置服务器以及绑定域名的具体步骤。文章还提供了详细的命令行操作指南,帮助读者顺利完成建站过程。 ... [详细]
  • Microsoft即将发布WPF/E的CTP(Community Technology Preview)和SDK,标志着RIA(Rich Internet Application)技术的新里程碑。更多详情及下载链接请参见MSDN官方页面。 ... [详细]
author-avatar
手机用户2602903963
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有