ServerTrustManager
open class ServerTrustManager : @unchecked Sendable
Responsible for managing the mapping of ServerTrustEvaluating values to given hosts.
-
Determines whether all hosts for this
ServerTrustManagermust be evaluated.trueby default.Declaration
Swift
public let allHostsMustBeEvaluated: Bool -
The dictionary of policies mapped to a particular host.
Declaration
Swift
public let evaluators: [String : any ServerTrustEvaluating] -
Initializes the
ServerTrustManagerinstance with the given evaluators.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.
Declaration
Swift
public init(allHostsMustBeEvaluated: Bool = true, evaluators: [String : any ServerTrustEvaluating])Parameters
allHostsMustBeEvaluatedThe value determining whether all hosts for this instance must be evaluated.
trueby default.evaluatorsA dictionary of evaluators mapped to hosts.
-
Returns the
ServerTrustEvaluatingvalue for the given host, if one is set.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.
Throws
AFError.serverTrustEvaluationFailedifallHostsMustBeEvaluatedistrueand no matching evaluators are found.Declaration
Swift
open func serverTrustEvaluator(forHost host: String) throws -> (any ServerTrustEvaluating)?Parameters
hostThe host to use when searching for a matching policy.
Return Value
The
ServerTrustEvaluatingvalue for the given host if found,nilotherwise.
View on GitHub
Install in Dash