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.
Here is class for requests:
import UIKit
import AFNetworking
class 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
}
}
}
I do requests by:
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)
})
And according to this post I have to use validatesCertificateChain
property. Can anybody help?