Swift 无法加载资源,因为应用程序传输安全策略要求使用安全连接。?
我甚至在info.plist文件中添加了。但似乎什么都不管用。由于这个原因,我在使用Alamofire的API方面面临问题Swift 无法加载资源,因为应用程序传输安全策略要求使用安全连接。?,swift,swift2,ios9,Swift,Swift2,Ios9,我甚至在info.plist文件中添加了。但似乎什么都不管用。由于这个原因,我在使用Alamofire的API方面面临问题 <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <false/> <key>NSExceptionDomains</key>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<false/>
<key>NSExceptionDomains</key>
<dict>
<key>"https://test.idelivr.com"</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads
NSExceptionDomains
"https://test.idelivr.com"
n包括多个域
NSTemporary ExceptionalLowsInSecureHttpLoads
NSTemporaryExceptionMinimumTLSVersion
TLSv1.1
尝试将其添加到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>
…
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
…
NSAppTransportSecurity
NSAllowsArbitraryLoads
将arbitraryLoads设置为true。事实上,我试图在错误的info.plist文件中进行更新。我的坏:(这是我添加的代码,现在对我来说效果很好
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>test.test.com</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionRequiresForwardSecrecy</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>
NSAppTransportSecurity
NSExceptionDomains
test.test.com
NSAllowsArbitraryLoads
n包括多个域
N异常低安全Http负载
NSExceptionRequiresForwardSecretary
NSExceptionMinimumTLSVersion
TLSv1.2
N第三方异常低安全Http负载
N第三方例外要求转发保密
第三方例外最小版本
TLSv1.2
NSRequiresCertificateTransparency
也有可能重复:(很好的例子)使用NSAllowsArbitraryLoads=true
是一种解决应用程序传输安全问题的方法,它不是通用的答案。在我们的例子中,OP似乎想在他们的域中使用https。