IdentityHelper

public class IdentityHelper

Helper for converting SecIdentity to PKCS #12 Data and vice versa

  • Singleton - provides a globally accessible, shared instance of this object

    Declaration

    Swift

    public internal(set) static var shared: IdentityHelper { get }
  • Default passphrase to encode the user identity

    Declaration

    Swift

    public static let passphrase: String
  • Converts SecIdentity to PKCS #12 Data

    Declaration

    Swift

    public func pkcs12Data(fromIdentity identity: SecIdentity, passphrase: String = passphrase) throws -> Data

    Parameters

    identity

    SecIdentity

    Return Value

    Data with PKCS #12 content

  • Converts PKCS #12 Data to SecIdentity

    The method uses only the first identity item from the data

    Declaration

    Swift

    public func identity(fromPKCS12Data pkcs12Data: Data, passphrase: String = passphrase) throws -> (identity: SecIdentity, certificates: [SecCertificate]?)

    Parameters

    pkcs12Data

    PKCS #12 Data

    passphrase

    String to open the PKCS #12 Data

    Return Value

    SecIdentity that was stored in the PKCS #12 Data

  • Converts PKCS #12 Data to URLCredential

    Throws

    IdentityError.failedToCreateIdentity if the PKCS #12 import failed

    Declaration

    Swift

    public func urlCredentialFromIdentity(identityData: Data, passphrase: String = passphrase) throws -> URLCredential

    Parameters

    identityData

    Data that contains the identity

    passphrase

    String to import the PKCS #12 data

    Return Value

    URLCredential with the identity and the certificate CAs