http://andrewmarinov.com/parsing-json-swift-4/
我将收到一个Json文件,但我收到错误:
TIC SSL信任错误
SURLSession / NSURLConnection HTTP加载失败
我无法改变服务器上的任何内容!
我可以在swift 4 / IOS11中使用一些代码来修复它吗?
这是我更改的Plist:
<dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
谢谢!
func urlSession(_ session: URLSession,didReceive challenge: URLAuthenticationChallenge,completionHandler: @escaping (URLSession.AuthChallengedisposition,URLCredential?) -> Void) { if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate) { completionHandler(.rejectProtectionSpace,nil) } if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) { let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!) completionHandler(.useCredential,credential) } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。