我正在尝试向我的个人网站发出一个alamofire GET请求,但我还没有ssl。我尝试将以下几行代码添加到info.plist中,但仍然没有成功:
1)完全禁用
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>2)允许我的个人url
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>yourserver.com</key>
<dict>
<!--Include to allow subdomains-->
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>但我一直收到同样的错误...
2016-03-19 13:02:07.770 appName[51705:9917289] 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.
[Request]: <NSMutableURLRequest: 0x7fcc92032140> { URL: http://www.myurl.com/sup?geoSearchWord=test }
[Response]: nil
[Data]: 0 bytes
[Result]: FAILURE: Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." 发布于 2020-04-13 08:49:23
Swift 5.2:您需要在info.plist中添加一个名为“应用传输安全设置”的字典,并在其中添加一个名为"Allow Arbitrary“的键,其值为"YES”,如下所示:

发布于 2016-03-20 04:11:26
第一个解决方案应该是可行的。确保将该代码放在第一个<dict>标记下的Info.plist中。还要确保您更改的plist是项目设置Build settings -> Info.plist file中使用的plist。
发布于 2019-05-25 04:46:53
您必须在.plist文件的NSAppTransportSecurity字典下将NSAllowsArbitraryLoads键设置为YES。

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