我读了很多关于它的问题,但仍然有问题。
当我使用localhost并从模拟器中更正NSAppTransportSecurity optinos时,一切都是正确的。
现在,我正在使用iPhone进行调试。iPhone和Mac都连接到同一网络。
我检查了我的Mac的IP地址
我将其添加到NSAppTransportSecurity中,如下所示:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>10.250.x.x</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
我仍然收到错误:
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
error = Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x7f904d300170 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}, NSErrorFailingURLStringKey=http://10.250.x.x:8080/IVRServer/api/registration/register, NSErrorFailingURLKey=http://10.250.x.x:8080/IVRServer/api/registration/register, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}
我应该在我的列表中添加其他内容吗?
请不要考虑重复此问题,因为我已经在我的plist中使用了正确的设置,并且工作正常,但是只是当我将服务器更改为非本地主机时,它却无法正常工作
我想念什么?
如果您只想绕过此限制,请允许所有负载:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
这应该是可行的,因为大概您正在使用“本地主机”,因此不应有任何安全问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句