App TranSport安全,升级到IOS 10.1后允许任意加载不工作

2024-01-04

我有一个在 ios 9 和 10.0 中运行良好的应用程序(我已将“允许任意负载 = YES”的应用程序传输安全阻止添加到我的 info.plist 中。但是升级到 10.1 和 Xcode 8.1 后似乎存在问题应用程序传输安全性。我无法连接到服务器。我的服务器仅支持 TLS 1.1

显示此错误

Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

可能是 IOS 10.1 忽略 .plist 信息。 (请注意,在 9.3 到 10.0 上它仍然工作正常)。

我的 .plist 文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>SingPost</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.8.7</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb1540614276180366</string>
            </array>
            <key>Item 0</key>
            <string>fb1540614276180366</string>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>1.8.7</string>
    <key>FacebookAppID</key>
    <string>1540614276180366</string>
    <key>FacebookDisplayName</key>
    <string>Singpost</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
        <key>NSAllowsArbitraryLoadsInWebContent</key>
        <true/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>prdesb1.singpost.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
                <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>mobile.singpost.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
                <key>NSTemporaryExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
        </dict>
    </dict>
    <key>NSCameraUsageDescription</key>
    <string>$(PRODUCT_NAME) camera use</string>
    <key>NSLocationAlwaysUsageDescription</key>
    <string>    </string>
    <key>NSLocationWhenInUseUsageDescription</key>
    <string>    </string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>$(PRODUCT_NAME) uses photos</string>
    <key>UIAppFonts</key>
    <array>
        <string>OpenSans-Regular.ttf</string>
        <string>OpenSans-Bold.ttf</string>
        <string>OpenSans-Semibold.ttf</string>
        <string>OpenSans-Light.ttf</string>
        <string>OpenSans-LightItalic.ttf</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
        <string>remote-notification</string>
    </array>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true/>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
</dict>
</plist>

我修复了添加例外域但在控制台中出现此错误

NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) –

根据建议进行编辑。我将我的 plist 更改为

<key>mobile.singpost.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>
            <key>mysam.sg</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <false/>
            </dict>

通过指定NSAllowsArbitraryLoadsInWebContent,你压倒一切NSAllowsArbitraryLoads在 iOS 10 上。

在 iOS 10 及更高版本以及 macOS 10.12 及更高版本中,[的值NSAllowsArbitraryLoads] 键被忽略如果您的应用程序的 Info.plist 文件中存在以下任何键:

  • NSAllowsArbitraryLoadsForMedia
  • NSAllowsArbitraryLoadsInWebContent
  • NS 允许本地网络

Source: 应用程序传输安全字典主键 https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW34 (Apple)

此外,NSExceptionDomain您提供的词典似乎与当前的文档格式 https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW35。具体来说,键不匹配:

  • NSTemporaryExceptionAllowsInsecureHTTPLoads应该NSExceptionAllowsInsecureHTTPLoads

  • NSTemporaryExceptionMinimumTLSVersion应该NSExceptionMinimumTLSVersion

  • NSTemporaryExceptionRequiresForwardSecrecy应该NSExceptionRequiresForwardSecrecy

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

App TranSport安全,升级到IOS 10.1后允许任意加载不工作 的相关文章

  • Swift:长按手势识别器 - 检测轻击和长按

    我想连接一个动作 如果手势是点击 它会以特定的方式为对象设置动画 但如果按下持续时间超过 0 5 秒 它会执行其他操作 现在 我刚刚连接了动画 我不知道如何区分长按和点击 如何访问新闻持续时间以实现上述目的 IBAction func ta
  • 如何删除 UITableView 中的缩进?

    首先 我对此很陌生 我很可能忘记了一些非常简单的事情 问题 我正在制作一个应用程序 在 a 中显示来自 imgur com 的随机图像tableView 由于某种原因 所有单元格都会缩进少量 如下图所示 我摆弄了许多设置storyboard
  • Xcode 异步单元测试在主线程上等待

    我正在尝试使用 Xcode 中的单元测试来测试一些异步代码 但主线程被阻塞 问题在于 某些正在测试的代码期望从 iOS 类 AVFoundation 接收回调 但是 AVFoundation 类似乎只会在主线程上回调 问题是 如果我正在进行
  • UICollectionView setLayout:animated: 不保留 zIndex

    我注意到打电话时setLayout animated in a UICollectionView要在两个布局之间切换 当前可见的单元格不遵循zIndex它的布局属性已设置在layoutAttributesForItemAtIndexPath
  • iOS:Facebook 登录访问令牌错误:由于模拟器错误,回退到从 NSUserDefaults 加载访问令牌

    根据说明进行配置后 我不断收到此错误 并且无法在我的应用程序上成功使用 Facebook 登录 我在 XCode 8 1 上运行它并使用 iOS 10 1 模拟器 我按照 Facebook iOS SDK 指南中的步骤操作 并将 Faceb
  • 有没有办法在 onclick 触发时禁用 iPad/iPhone 上的闪烁/闪烁?

    所以我有一个有 onclick 事件的区域 在常规浏览器上单击时 它不会显示任何视觉变化 但在 iPad iPhone 上单击时 它会闪烁 闪烁 有什么办法可以阻止它在 iPad iPhone 上执行此操作吗 这是一个与我正在做的类似的示例
  • 诊断和仪器均缺少“僵尸”选项

    运行 Xcode 4 0 2 Zombie 选项丢失 其他 SO 帖子建议找到它的两个地方 Product gt Run looks like this Product gt Profile looks like this 奇怪的是 我之前
  • ios8 键盘高度有所不同

    我使用下面的代码来获取键盘高度 该高度在带有 ios8 的 iPhone 5s 设备中与带有 ios7 的 IPhone4s 设备中有所不同 因此 当我在带有 ios8 的 iPhone5s 中点击它时 我的文本字段移动得非常高 而相同的代
  • 使用强光混合模式时突出显示伪影

    我正在 iPhone 应用程序中使用顶部图像的 HardLight 混合模式混合两个图像 它看起来像这样 UIGraphicsBeginImageContext size sourceImage drawInRect rectangle b
  • Unwind segue 的用途是什么以及如何使用它们?

    iOS 6 和 Xcode 4 5 有一个称为 Unwind Segue 的新功能 展开转场可以允许过渡到故事板中场景的现有实例 除了 Xcode 4 5 发行说明中的 这个简短条目之外 UIViewController 现在似乎还有几个新
  • 节拍匹配算法

    我最近开始尝试创建一个移动应用程序 iOS Android 它将自动击败比赛 http en wikipedia org wiki Beatmatching http en wikipedia org wiki Beatmatching 两
  • 无效的捆绑包...包含不允许的文件“frameworks”

    我尝试通过应用程序加载器发布我的应用程序 但我不断收到此错误 我试过了这个解决方案 https stackoverflow com questions 25777958 validation error invalid bundle the
  • 如何在 Objective C 中使用 swift 文件

    我想在 Objective C 代码中使用我的 Swift 文件 我找到了不同的链接 说明了如何操作 我的项目名称是 测试项目 我将 import Test Project Swift h 导入到我的 m 文件中 以在 Objective
  • 使用可达性有什么好处?

    与下面的代码相比 使用 Reachability 有什么优势 我觉得 Reachability 有大量代码 但如果它在任何方面更好 那么我会使用它 NSString connectionString NSString alloc initW
  • 如何去除 UIImageView 遮罩后的透明区域?

    在我的一个 iOS 应用程序中 我尝试使用以下命令剪切图像的一部分CGImageMask 我已成功使用以下代码屏蔽图像 UIImage maskImage UIImage referenceImage withMask UIImage ma
  • 动态图标 iOS [重复]

    这个问题在这里已经有答案了 可能的重复 每天更改图标 https stackoverflow com questions 4038305 changing icon per day 如何制作动态图标 例如在日历中 每天该数字都会更改为当前值
  • CoreBluetooth广告检测时间

    这个问题早在10月份就已经讨论过here https stackoverflow com questions 12866551 corebluetooth connection setup time varies quite a bit 1
  • 图像高斯模糊 - iOS 8

    我有一个移动的背景图像 我想模糊它的底部 我would只用 Photoshop 就能做到 但由于图像会移动 效果不太好 这就是我的意思 看图片底部 基本上就像底座对 iPhone 的影响一样 我使用的是 iOS 8 但不是 Swift 我根
  • Xcode 6.1“Xcode 调试器中内置的 Swift REPL 可以检查和操作正在运行的应用程序”不起作用

    对于 Xcode 6 1 更新点之一是 Xcode 调试器内置的 Swift REPL 可以检查和操作 你的跑步应用程序 我创建了空项目 在 viewDidLoad 中设置了一个断点 当应用程序在断点处停止时 我在 Xcode 控制台中输入
  • NSData 不接受有效的 base64 编码字符串

    我正在 iOS 7 客户端实现 JSON Web Token 身份验证 效果很好 我的应用程序接收令牌 并可以使用它们对我的服务器进行经过身份验证的调用 现在 我希望我的客户端代码检查令牌的过期日期 以便它知道何时重新进行身份验证 检查 J

随机推荐