首页 文章

获取App Transport Security问题

提问于
浏览
2

嘿,我收到这个错误:

App Transport Security已阻止明文HTTP(http://)资源加载,因为它不安全 . 可以通过应用程序的Info.plist文件配置临时例外 .

当尝试从网络上获取图像时,我知道这必须与iOS9应用程序传输安全性有关,但问题是在我的plist中我将 Allow Arbitrary Loads 设置为true .

更多的是,我真的找不到更多的解决方案来解决这个问题 .

有没有人有任何想法?

enter image description here

1 回答

  • 2

    Exception Domains 中,您可以为特定域定义安全性 . 在此词典中,您可以覆盖 NSAllowArbitoryLoads 定义的内容,例如:

    NSAppTransportSecurity
        NSAllowsArbitraryLoads = YES  
        NSExceptionDomains
            "unsecure-server-i-control.example.com"
            NSExceptionAllowsInsecureHTTPLoads = NO
    

    通常允许任意加载,但特别是对于 unsecure-server-i-control.example.com 它们是不允许的 .

    有关更多信息,请参阅NSAppTransportSecurity in Apple docs

相关问题