如何在iOS 9中加载HTTPS URL?
我需要在info.plist中设置什么才能启用HTTPS模式?我已经把这个放在我的plist里了:如何在iOS 9中加载HTTPS URL?,ios,objective-c,Ios,Objective C,我需要在info.plist中设置什么才能启用HTTPS模式?我已经把这个放在我的plist里了: <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict> NSAppTransportSecurity NSAllowsArbitraryLoads 但它不起作用,我还是会
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
NSAppTransportSecurity
NSAllowsArbitraryLoads
但它不起作用,我还是会犯这个错误
错误消息:-
2016-02-25 12:46:31.860印度河音频[707:13224]NSURLSession/NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9813)
2016-02-25 14:20:31.119 Indus Audio[817:23670]响应:(null)Error Domain=NSURLErrorDomain Code=-1202“此服务器的证书无效。您可能正在连接假装为“www.indusaudio.com”的服务器,这可能会使您的机密信息面临风险。”
UserInfo={NSURlerErrorFailingUrlPeerTrustErrorKey=,NSLocalizedRecoverySuggestion=是否仍要连接到服务器?,kCFStreamErrorDomainKey=3,kCFStreamErrorCodeKey=-9813,
NSErrorPeerCertificateChainKey={type=不可变,计数=1,值=(
0 :
)},NSUnderlyingError=0x7f9e58e05cf0{Error Domain=KCFerrorDomain=KCF网络代码=-1202“(null)”用户信息={kCFStreamPropertySSLClientCertificateState=0,kCFStreamPropertySSLPeerTrust=,KCFnetworkCFstreamsSrorOriginalValue=-9813,kCFStreamErrorDomainKey=3,KCFStreamerCodeKey=-9813,KCFStreamPropertySlPeerCertificates={type=不可变,count=1,value=(
0 :
)}}},
URL:https://www.xxxxx.com/xxx/xxx/files/downloadFile/en/linto
更新:
更好地更新服务器以支持SSL和TLSv1.2
此方法仅用于临时使用。此方法并非完全可取:
<key>NSAppTransportSecurity</key>
<dict>
<!--Connect to anything. Not advisable. For desperate measures I guess-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
在info.plist文件中添加应用程序传输安全设置,并将允许任意加载项设置为“是”。此问题有完全相同的错误代码:给定错误代码,您的服务器很可能缺少中间证书。如果在Safari iOS、Safari Mac或其他浏览器中打开相同的URL,会发生什么情况owser?事实上,我曾经通过chrome中一个名为Advanced client的扩展打开这些URL。在那里,它可以正常工作,并且这些URL在android perfectlycan中工作。你可以告诉我如何在我的应用程序中添加这些信息吗?你可以只添加“应用程序传输安全设置”键和添加嵌套键“允许任意加载”然后将其设置为“是”。这将允许你的应用程序连接到任何URL,这不是执行作业的安全方式,而不是
https://www.xxxxx.com/xxx/xxx/files/downloadFile/en/linto
,请尝试http://www.xxxxx.com/xxx/xxx/files/downloadFile/en/linto
我尝试了,但后端不支持http和httpsI。我已更新了答案,但请考虑更新服务器。
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>enterYourUrlHere.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>