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 more

    Declaration

    Swift

    public enum CertificateType
  • Errors that can be thrown from the UnbluAuthenticationChallengeCertificate

    See more

    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 is Bundle.main.

  • Initializes the certificate with a specific CertificateType and the Data 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 certificate Data

    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 certificate Data

    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.