ServerTrustManager
public final class ServerTrustManager
extension ServerTrustManager: URLCredentialProvider
This class is the default credential provider for URLAuthenticationMethod.serverTrust.
It conforms to the URLCredentialProvider protocol.
The purpose of this class is to make certificate pinning easy to set up. All the
heavy lifting is done by this class and APIRequestType.
The caller only needs to call the necessary API to pin a certificate
or SPKI fingerprint for their server.
-
Uses the provided certificate to pin the SPKI for the specified host. If SPKI cannot be extracted for the specified certificate then this falls back to public key pinning.
Declaration
Swift
public static func pin(certificate: SecCertificate, forHost host: String)Parameters
certificateSecCertificate object to pin
hostThe host name string to pin for this certificate. e.g. www.microstrategy.com
-
Pins the SPKI fingerprint for the specified host.
Declaration
Swift
public static func pin(spkiFingerprint fingerprint: String, forHost host: String)Parameters
spkiFingerprintSPKI bytes -> SHA 256 -> base64 string
hostThe host name string to pin for this SPKI. e.g. www.microstrategy.com
-
Discard any pinning data for the specified host name.
Declaration
Swift
public static func unpinTLSCertificate(forHost host: String)
ServerTrustManager Class Reference