UnbluAuthenticationChallengeCertificate
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
enum CertificateType -
Errors that can be thrown from the
UnbluAuthenticationChallengeCertificateDeclaration
Swift
enum ChallengeCertificateError -
Initializes the certificate using a filename, extension, and an optional bundle.
Throws
UnbluAuthenticationChallengeCertificate.ChallengeCertificateErrorif 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
init(name: String, extension: String, in bundle: Bundle = .main) throwsParameters
nameThe filename of the certificate bundled in your app.
extensionThe extension of the certificate bundled in your app.
-
Initializes the certificate with a specific
CertificateTypeand theDatafor that certificate.Throws
UnbluAuthenticationChallengeCertificate.ChallengeCertificateErrorif 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
init(type: UnbluAuthenticationChallengeCertificate.CertificateType, data: Data) throwsParameters
typeThe
CertificateTypefor the given certificateDatadataThe
Datafor the certificate -
Initializes the certificate for public key pinning with a specific
CertificateTypeand the raw public key.Throws
UnbluAuthenticationChallengeCertificate.ChallengeCertificateErrorif 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
init(type: UnbluAuthenticationChallengeCertificate.CertificateType, publicKey: String) throwsParameters
typeThe
CertificateTypefor the given certificateDatapublicKeyThe 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.