本文介绍了AFNetworking 3问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 在 AFNetworking 3中,对于无效的SSL证书,我使用了 validatesCertificateChain = false ,但是现在看来该字段已被删除,我无法向我的服务器发出请求。In AFNetworking 3 for invalid SSL certificate I used validatesCertificateChain = false , but now it seems that this field was removed and I can't make requests to my server. 以下是要求类:import UIKitimport AFNetworkingclass ClientHTML: AFHTTPSessionManager { private static var __once: () = { () -> Void in let securityPolicy = AFSecurityPolicy(pinningMode: AFSSLPinningMode.certificate) securityPolicy.validatesDomainName = false securityPolicy.allowInvalidCertificates = true sharedInstanceTemp.securityPolicy = securityPolicy sharedInstanceTemp.requestSerializer = AFHTTPRequestSerializer() sharedInstanceTemp.responseSerializer = AFHTTPResponseSerializer() }() fileprivate static let sharedInstanceTemp = ClientHTML(baseURL: URL(string: kServer_urlBilderlings)) static var sharedInstance:ClientHTML { get { _ = ClientHTML.__once return sharedInstanceTemp } }} 我通过以下方式提出请求:ClientHTML.sharedInstance.post("https://acs-web-test.firstdata.lv", parameters: nil, progress: { (progress) in print("progress = ", progress) }, success: { (task, response) in let data = response as! Data let html = String(data: data, encoding: .utf8) print("success responce = ", html) }, failure: { (task, error) in print("error = ", error) })然后根据这篇文章使用 validatesCertificateChain 属性。有人可以帮忙吗?And according to this post I have to use validatesCertificateChain property. Can anybody help?推荐答案我通过更改 let securityPolicy = AFSecurityPolicy(pinningMode:AFSSLPinningMode.certificate )到 let securityPolicy = AFSecurityPolicy(pinningMode:AFSSLPinningMode.none) 这篇关于AFNetworking 3问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-14 06:25