ServerTrustPolicyManager

open class ServerTrustPolicyManager

Responsible for managing the mapping of ServerTrustPolicy objects to a given host.

  • The dictionary of policies mapped to a particular host.

    Declaration

    Swift

    open let policies: [String: ServerTrustPolicy]
  • Initializes the ServerTrustPolicyManager instance with the given policies.

    Since different servers and web services can have different leaf certificates, intermediate and even root certficates, 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(policies: [String: ServerTrustPolicy])
  • Returns the ServerTrustPolicy for the given host if applicable.

    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.

    Declaration

    Swift

    open func serverTrustPolicy(forHost host: String) -> ServerTrustPolicy?