UnbluAuthenticationChallengeHandler
public class UnbluAuthenticationChallengeHandler
extension UnbluAuthenticationChallengeHandler: AuthenticationChallengeDelegate
The authentication challenge handler provided by Unblu allows you to provide certificate Data
and public keys to be used in certificate pinning.
You can provide as many certificates as you want.
If using this class, you should initialize using UnbluAuthenticationChallengeCertificate
or a dictionary containing UnbluAuthenticationChallengePolicy
objects.
Example of initialization using UnbluAuthenticationChallengeCertificate
:
do {
let certificate = try UnbluAuthenticationChallengeCertificate(name: "certificate", extension: "cer")
let challengeHandler = UnbluAuthenticationChallengeHandler(data: [certificate])
} catch {
}
Example of initialization using UnbluAuthenticationChallengePolicy
:
do {
let certificate = try UnbluAuthenticationChallengeCertificate(name: "certificate", extension: "cer")
let policies = [
"example.com": UnbluAuthenticationChallengePolicy(certificates: [certificate])
]
let challengeHandler = UnbluAuthenticationChallengeHandler(policies: policies)
} catch {
}
-
Initializes the class with an Array of
UnbluAuthenticationChallengeCertificate
objects and no hosts to check against.Example of initialization:
do { let certificate = try UnbluAuthenticationChallengeCertificate(name: "certificate", extension: "cer") let challengeHandler = UnbluAuthenticationChallengeHandler(data: [certificate]) } catch { }
Declaration
Swift
public convenience init(data: [UnbluAuthenticationChallengeCertificate])
Parameters
data
An Array of
UnbluAuthenticationChallengeCertificate
objects representing the certificates to check when the UnbluCoreSDK receives an authentication challenge. -
Initializes the class with a Dictionary of policies and their respective host.
Example of initialization:
do { let certificate = try UnbluAuthenticationChallengeCertificate(name: "certificate", extension: "cer") let policies = [ "example.com": UnbluAuthenticationChallengePolicy(certificates: [certificate]) ] let challengeHandler = UnbluAuthenticationChallengeHandler(policies: policies) } catch { }
Declaration
Swift
public convenience init(policies: [String : UnbluAuthenticationChallengePolicy])
Parameters
policies
A Dictionary containing Key Value pairs for a host and an
UnbluAuthenticationChallengePolicy
. In order for a policy to be satisfied, the Key value must match the host name in a leaf certificate for a given challenge AND the challenge certificate must match a certificate defined inUnbluAuthenticationChallengePolicy
. -
Initializes the class with a
Dictionary
of policies and their respective hosts and/or with the filename and password of a PKCS12 file for client certificate authentication (mTLS).}“`
Declaration
Swift
public convenience init(policies: [String : UnbluAuthenticationChallengePolicy], pkcs12FileName: String = "", pkcs12Password: String = "")
Parameters
policies
A
Dictionary
containing key-value pairs for a host and anUnbluAuthenticationChallengePolicy
. For a policy to be satisfied, the key must match the host name in a leaf certificate for a given challenge AND the challenge certificate must match a certificate defined inUnbluAuthenticationChallengePolicy
. -
Initializes the class with the filename and password of a PKCS12 file for client certificate authentication (mTLS). This initialization is for cases that are only supposed to use only client certificate authentication.
Declaration
Swift
public convenience init(pkcs12FileName: String, pkcs12Password: String)
-
Declaration
Swift
public func didReceive(authenticationChallenge challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)