我的请求看起来像
let headers = ["Host:" : "www.fortune500companysite.com", "User-Agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:50.0) Gecko/20100101 Firefox/50.0", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language" : "en-US,en;q=0.5", "Connection" : "keep-alive", "Upgrade-Insecure-Requests" : "1"]
let request = formatRequest(url: "https://www.fortune500companysite.com/", method: "GET", headers: headers, dataString: nil)
我需要帮助格式化我的info.plist,以便请求(和子域请求)正常工作,苹果可以批准该应用。
发送请求仅适用于:
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
我们知道,这是让苹果拒绝您的应用程序的单程票。没有它,我收到以下错误:
nw_coretls_read_one_record tls_handshake_process: [-9824]
error: Optional(Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={NSUnderlyingError=0x60800004ea60 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=54, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://www.fortune500companysite.com/, NSErrorFailingURLKey=https://www.fortune500companysite.com/, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=54, NSLocalizedDescription=The network connection was lost.})
我在别人的问题中找到的这段代码无济于事
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>fortune500companysite.com</key>
<dict>
<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>
<true/>
<key>NSThirdPartyExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
<key>NSRequiresCertificateTransparency</key>
<false/>
</dict>
</dict>
</dict>