我面临着使用IP地址连接API的问题。即使我在plist中添加了以下代码,它仍然显示错误如下:
"http://xx3.xx.xx8.xx7/xxx/xxx/错误:无法加载资源,因为策略要求使用安全连接。“
这是我添加到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>发布于 2015-09-22 08:46:35
文档在这里允许与单个服务器的不安全连接。因此,您必须像show一样将NSAppTransportSecurity添加到您的info.plist文件中(要在源代码中显示Info.plist,在Xcode中右键单击Info.plist "Open“->源代码”)。
配置每个域异常:
<?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>编辑Infor.plist文件后,如下所示:

或禁用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>编辑Infor.plist文件后,如下所示:

发布于 2017-08-26 09:01:55
简单且最简单的解决方案,只需3步

添加以下两个属性&再次运行..。快乐编码:-)

https://stackoverflow.com/questions/32712155
复制相似问题