gpt4 book ai didi

ios - 应用程序传输安全策略要求使用安全连接 - IOS 9

转载 作者:可可西里 更新时间:2023-11-01 04:07:47 25 4
gpt4 key购买 nike

我在使用 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>

最佳答案

文档 Allowing Insecure Connection to a Single Server here .因此,您必须以真实的方式将 NSAppTransportSecurity 添加到您的 info.plist 文件中(要在源代码中显示 Info.plist,在 Xcode 中右键单击 Info.plist“打开为”->“源代码” )

配置每个域的异常(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>
<!--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 文件后如下所示: enter image description here

或禁用 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 文件后如下所示: enter image description here

关于ios - 应用程序传输安全策略要求使用安全连接 - IOS 9,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32712155/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com