应用传输安全策略要求使用安全连接 - IOS 9 [英] App Transport Security policy requires the use of a secure connection - IOS 9

查看:1055
本文介绍了应用传输安全策略要求使用安全连接 - IOS 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用IP地址时遇到API连线问题。即使我已经添加以下代码到plist,它仍然显示错误如下:





或停用ATS:

 <?xml version =1.0encoding =UTF-8?> 
<!DOCTYPE plist PUBLIC - // Apple // DTD PLIST 1.0 // ENhttp://www.apple.com/DTDs/PropertyList-1.0.dtd\">
< plist version =1.0>
< dict>
...
< key> NSAppTransportSecurity< / key>
< dict>
<! - 包括以允许所有连接(危险) - >
< key> NSAllowsArbitraryLoads< / key>
< true />
< / dict>
< / dict>
< / plist>

编辑后的Infor.plist文件如下所示:


I'm facing problem connection to API with using IP address. Even I had add the following code to plist, it still show error as below:

"http://xx3.xx.xx8.xx7/xxx/xxx/ error: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."

This is the code I add to the plist

     <key>xx3.xx.xx8.xx7</key>
        <dict>
            <key>NSThirdPartyExceptionMinimumTLSVersion</key>
            <string>TLSv1.1</string>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </key>

解决方案

document here. So you must add NSAppTransportSecurity to your info.plist file in truth way like flowing (to show Info.plist in source, in Xcode right click to Info.plist "Open As"->"Source Code")

To configure a per-domain exception:

<?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>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>your_domain_here</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                <true/>
                <key>NSThirdPartyExceptionMinimumTLSVersion</key>
                <string>TLSv1.2</string>
                <key>NSRequiresCertificateTransparency</key>
                <true/>
            </dict>
        </dict>
    </dict>
</dict>
</plist>

after edit Infor.plist file look like following:

or disable ATS:

<?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>NSAppTransportSecurity</key>
    <dict>
        <!--Include to allow all connections (DANGER)-->
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
</dict>
</plist>

after edit Infor.plist file look like following:

这篇关于应用传输安全策略要求使用安全连接 - IOS 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆