美文网首页
ATS安全策略

ATS安全策略

作者: 4VZhang | 来源:发表于2020-12-15 11:36 被阅读0次
    "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." 
    UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLStringKey=http://mysever.com/login/signin, 
    NSErrorFailingURLKey=http://mysever.com/login/signin, }
    

    方法1.全局允许http请求

    <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            < true/>
        </dict>
    

    方法2.除白名单以外只允许https请求

        <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <false/>
            <key>NSExceptionDomains</key>
            <dict>
                <key>httpDomainName.com</key>
                <dict>
                    <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                    <true/>
                    <key>NSIncludesSubdomains</key>
                    <true/>
                </dict>
            </dict>
        </dict>
    

    其中httpDomainName.com替换为自己的http的域名,白名单可以添加多个域名

    相关文章

      网友评论

          本文标题:ATS安全策略

          本文链接:https://www.haomeiwen.com/subject/cbzigktx.html