in alamofire 4 I used this code to disable sever evaluation:
private var Manager : Alamofire.Session = {
// Create the server trust policies
let serverTrustPolicies: [String: ServerTrustPolicy] = ["serverurl.com": .disableEvaluation]
// Create custom manager
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = Alamofire.Session.defaultHTTPHeaders
let man = Alamofire.Session(
configuration: URLSessionConfiguration.default,
serverTrustPolicyManager: ServerTrustManager(policies: serverTrustPolicies)
)
return man
}()
but is not working anymore in alamofire 5 with swift 5 xcode 10.2, I got this errors.
Use of undeclared type 'ServerTrustPolicy' Type 'Session' has no member 'defaultHTTPHeaders'
but I cant find a new way to make this work with alamofire 5.
Alamofire is an HTTP networking library written in Swift. Alamofire helps to improve the quality of code. It is a simpler way to consume REST services. Alamofire is the basic tool for hundreds of projects.
Alamofire is a Swift-based, HTTP networking library. It provides an elegant interface on top of Apple's Foundation networking stack that simplifies common networking tasks. Its features include chainable request/response methods, JSON and Codable decoding, authentication and more.
ServerTrustPolicy
has been replaced with the protocol ServerTrustEvaluating
in Alamofire 5, and DisabledEvaluator
has replaced the .disabled
enum case. To replicate the custom setup you had before:
private let session: Session = {
let manager = ServerTrustManager(evaluators: ["serverurl.com": DisabledEvaluator()])
let configuration = URLSessionConfiguration.af.default
return Session(configuration: configuration, serverTrustManager: manager)
}()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With