UnbluAuthenticationChallengeCertificate
public struct UnbluAuthenticationChallengeCertificate
A Struct that enables the Unblu SDK to wrap your certificate data, and handle authentication challenges from your server. Use this when creating an instance of UnbluAuthenticationChallengePolicy
and/or an instance of UnbluAuthenticationChallengeHandler
.
-
The certificate types supported by the Unblu SDK
See moreDeclaration
Swift
public enum CertificateType
-
Errors that can be thrown from the
See moreUnbluAuthenticationChallengeCertificate
Declaration
Swift
public enum ChallengeCertificateError : Error
-
Initializes the certificate using a filename, extension, and an optional bundle.
Throws
UnbluAuthenticationChallengeCertificate.ChallengeCertificateError
if the certificate failed to initialize.For example, if you had a certificate bundled into your app as “certificate.cer”:
do { try UnbluAuthenticationChallengeCertificate(name: "certificate", extension: "cer") } catch { }
Declaration
Swift
public init(name: String, extension: String, in bundle: Bundle = .main) throws
Parameters
name
The filename of the certificate bundled in your app.
extension
The extension of the certificate bundled in your app.
bundle
The
Bundle
to look for the certificate in. The default value for this isBundle.main
. -
Initializes the certificate with a specific
CertificateType
and theData
for that certificate.Throws
UnbluAuthenticationChallengeCertificate.ChallengeCertificateError
if the certificate failed to initialize.For example, if you had a certificate bundled into your app as “certificate.cer”:
let certificateData: Data = ... do { try UnbluAuthenticationChallengeCertificate(type: .cer, data: certificateData) } catch { }
Declaration
Swift
public init(type: CertificateType, data: Data) throws
Parameters
type
The
CertificateType
for the given certificateData
data
The
Data
for the certificate -
Initializes the certificate for public key pinning with a specific
CertificateType
and the raw public key.Throws
UnbluAuthenticationChallengeCertificate.ChallengeCertificateError
if the certificate failed to initialize.For example:
let publicKey = """ -----BEGIN CERTIFICATE----- MIIEyTCCA7GgAwIBAgIRAOWJUBT/plbPAgAAAACAVf4wDQYJKoZIhvcNAQELBQAw QjELMAkGA1UEBhMCVVMxHjAcBgNVBAoTFUdvb2dsZSBUcnVzdCBTZXJ2aWNlczET ...(ommited additional lines)... -----END CERTIFICATE----- """ do { try UnbluAuthenticationChallengeCertificate(type: .pem, publicKey: publicKey) } catch { }
Declaration
Swift
public init(type: CertificateType, publicKey: String) throws
Parameters
type
The
CertificateType
for the given certificateData
publicKey
The raw String of the public key to pin. Make sure the String you pass is unmodified from the raw output. See the discussion for more.