【问题标题】:ATS warning but Temporary exception active?ATS 警告但临时异常处于活动状态?
【发布时间】:2016-07-25 17:00:47
【问题描述】:

我有一个奇怪的问题, 我不断收到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.,但我启用了异常,并为 ATS 打开了整个应用程序,但即使我的其他键正在使用中,Xcode 也会忽略我的偏好。

我想知道我做错了什么,谁能告诉我是否有什么东西让他们觉得我的钥匙有什么大错特错?

<?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>AUTH_SERVER_URL</key>
    <string>https://$(Auth_Server_Url)</string>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>MKDirectionsRequest</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.apple.maps.directionsrequest</string>
            </array>
        </dict>
    </array>
    <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>0.1</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fr.cityzenmobility.drivers</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>com.googleusercontent.apps</string>
            </array>
        </dict>
    </array>
    <key>CFBundleVersion</key>
    <string>6</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>MKDirectionsApplicationSupportedModes</key>
    <array>
        <string>MKDirectionsModeCar</string>
        <string>MKDirectionsModeStreetCar</string>
        <string>MKDirectionsModeTaxi</string>
    </array>

这是应该起作用的部分:

 <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <false/>
        <key>NSExceptionDomains</key>
        <dict>
            <key>www.mysite.fr</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
                <true/>
            </dict>
        </dict>
    </dict>

然后Info.plist文件结束:

    <key>SERVERURL</key>
    <string>http://${Server_Url}</string>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Welcome</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
</dict>
</plist>

编辑

我用完全相同的 Info.plist 构建了一个全新的项目。它可以工作,此后问题不在于网络部分本身。

【问题讨论】:

  • 看起来您的 NSThirdPartyException... 键的值是一个空字符串,而不是 true
  • @dan 很好发现,但遗憾的是它不能解决问题。我想我会做一个全新的项目来测试这个......
  • 刚刚发现了这个developer.apple.com/library/ios/qa/qa1887/_index.html#//…,希望能帮助解决这类问题。

标签: ios app-transport-security network-security


【解决方案1】:

由于某种奇怪的原因,在 Mac 完全重启、项目的 git 克隆、项目和构建文件以及 iPhone 的完全清理后,代码开始按预期运行。

我认为某些缓存文件行为不端...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-21
    • 2019-09-16
    相关资源
    最近更新 更多