首页 文章

Cleartext HTTP被阻止

提问于
浏览
2

更新到新发布的Xcode 7版本后,我遇到了这个问题 .

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. gete The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

我做了一些搜索,我发现解决方案说要将这些行添加到我项目中的info.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>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>com.thenewsapp.$(PRODUCT_NAME:rfc1034identifier)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>BNDL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>NSAppTransportSecurity</key>
<dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
       <key>NSExceptionDomains</key>
       <dict>
            <key>greenarea.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
            </dict>
       </dict>
</dict>
</dict>
</plist>

任何帮助

1 回答

  • 1

    提到here

    App Transport Security(ATS)在应用程序及其后端之间的安全连接中实施最佳实践 . ATS防止意外泄露,提供安全的默认行为,并且易于采用;它在iOS 9和OS X v10.11中默认启用 . 无论您是在创建新应用程序还是更新现有应用程序,都应尽快采用ATS . 如果您正在开发新的应用程序,则应该专门使用HTTPS . 如果您有现有应用,则应尽可能多地使用HTTPS,并创建一个计划,以便尽快迁移其余应用 . 此外,您通过更高级别的API进行的通信需要使用具有前向保密性的TLS 1.2版进行加密 . 如果尝试 Build 不符合此要求的连接,则会引发错误 . 如果您的应用需要向不安全的域发出请求,则必须在应用的Info.plist文件中指定此域 .

    很明显,你会从 http 开始 https 协议,直到那时这是变通方法

    除了你的plist中的 NSAllowsArbitraryLoads 之外,从 NSAppTransportSecurity dict中删除所有剩余的键

    enter image description here

相关问题