对于一些背景信息,我尝试显示的网页是当前托管在 AWS 的 EC2 上的 Web 应用程序。后端是 Python w/ Flask,前端只是简单的 HTML/CSS。该 URL 具有 HTTP,因为它尚未使用 HTTPS 进行保护。当打开该网页的 url 时,浏览器首先要求的是登录凭据(是浏览器询问,而不是网站)。这一页does在我的 iPhone 上的移动 Safari 中加载,Safari 确实成功地要求提供凭据。如果我正确输入它们,它将正确加载页面。
因此,我尝试了应用程序传输安全设置下的允许任意加载以及具有以下键的自定义异常域:
App Transport Security Settings Dictionary
Exception Domains Dictionary
my website URL Dictionary
NSIncludesSubdomains Boolean (YES)
NSExceptionAllowsInsecureHTTPLoads Boolean (YES)
NSThirdPartyExceptionAllowsInsecureHTTPLoads Boolean (YES)
NSExceptionMinimumTLSVersion String (TLSv1.0)
NSExceptionRequiresForwardSecrecy Boolean (YES)
但是,每当我在模拟器上启动应用程序时,我得到的只是白屏(如果需要,可以发布屏幕截图)。
这是我在 ViewController.swift 中的代码:
import UIKit
class ViewController: UIViewController {
@IBOutlet var WebView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "My URL inserted here")
let request = NSURLRequest(URL: url!)
WebView.loadRequest(request)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
如果我使用允许任意负载,当我查看输出框时,它确实not say "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.
“当我正确配置异常域(删除允许任意加载)时,它也不会给我该消息。只有有时当我使用异常域更改设置(再次删除允许任意加载)时,我才会得到此输出。
我开始认为这个问题超出了安全范围,非常感谢我可以采取的任何建议或步骤来尝试解决这个问题,谢谢!