我正在使用IP地址与API连接问题.即使我将以下代码添加到plist,它仍然显示如下错误:
" http://xx3.xx.xx8.xx7/xxx/xxx/错误:无法加载资源,因为App Transport Security策略要求使用安全连接."
这是我添加到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>
Run Code Online (Sandbox Code Playgroud)
lar*_*rva 15
文档允许在此处与单个服务器进行不安全连接.所以你必须NSAppTransportSecurity像你的流程一样添加到你的info.plist文件中(在源代码中显示Info.plist,在Xcode中右键单击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>
<!--others key-->
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>insecure-domain1.example.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
<key>insecure-domain2.example.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.0</string>
</dict>
</dict>
</dict>
<!--others key-->
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
或禁用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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22161 次 |
| 最近记录: |