ServerTrustManager - SwiftDocOrg/Alamofire GitHub Wiki
ServerTrustManager
Responsible for managing the mapping of ServerTrustEvaluating values to given hosts.
open class ServerTrustManager
Initializers
init(allHostsMustBeEvaluated:βevaluators:β)
Initializes the ServerTrustManager instance with the given evaluators.
public init(allHostsMustBeEvaluated:β Bool = true, evaluators:β [String:β ServerTrustEvaluating])
Since different servers and web services can have different leaf certificates, intermediate and even root certificates, it is important to have the flexibility to specify evaluation policies on a per host basis. This allows for scenarios such as using default evaluation for host1, certificate pinning for host2, public key pinning for host3 and disabling evaluation for host4.
Parameters
- allHostsMustBeEvaluated:β The value determining whether all hosts for this instance must be evaluated.
trueby default. - evaluators:β A dictionary of evaluators mapped to hosts.
Properties
allHostsMustBeEvaluated
Determines whether all hosts for this ServerTrustManager must be evaluated. true by default.
let allHostsMustBeEvaluated:β Bool
evaluators
The dictionary of policies mapped to a particular host.
let evaluators:β [String:β ServerTrustEvaluating]
Methods
serverTrustEvaluator(forHost:β)
Returns the ServerTrustEvaluating value for the given host, if one is set.
open func serverTrustEvaluator(forHost host:β String) throws -> ServerTrustEvaluating?
By default, this method will return the policy that perfectly matches the given host. Subclasses could override this method and implement more complex mapping implementations such as wildcards.
Parameters
- host:β The host to use when searching for a matching policy.
Throws
AFError.serverTrustEvaluationFailed if allHostsMustBeEvaluated is true and no matching evaluators are found.
Returns
The ServerTrustEvaluating value for the given host if found, nil otherwise.