ATS安全策略

2020-12-15  本文已影响0人  4VZhang
"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的域名,白名单可以添加多个域名

上一篇下一篇

猜你喜欢

热点阅读