TLSIdentity

@available(macOS 10.12, iOS 10.0, *)
public class TLSIdentity

ENTERPRISE EDITION ONLY.

TLSIdentity provides TLS Identity information including a key pair and X.509 certificate chain used for configuring TLS communication to the listener.

  • The certificate chain as an array of SecCertificate object.

    Declaration

    Swift

    public var certs: [SecCertificate] { get }
  • The identity expiration date which is the expiration date of the first certificate in the chain.

    Declaration

    Swift

    public var expiration: Date { get }
  • Get an identity from the Keychain with the given label.

    Declaration

    Swift

    public static func identity(withLabel label: String) throws -> TLSIdentity?
  • Get an identity with a SecIdentity object. Any intermediate or root certificates required to identify the certificate but not present in the system wide set of trusted anchor certificates need to be specified in the optional certs parameter. In additon, the specified SecIdenetity object is required to be present in the KeyChain, otherwise an exception will be thrown.

    Declaration

    Swift

    public static func identity(withIdentity identity: SecIdentity,
                                certs: [SecCertificate]?) throws -> TLSIdentity
  • Creates a self-signed identity and persist the identity in the Keychain with the given label. Note that the Common Name (certAttrCommonName) attribute is required. If the Common Name attribute is not included, an error will be returned.

    Declaration

    Swift

    public static func createIdentity(forServer server: Bool,
                                      attributes: [String: String],
                                      expiration: Date?,
                                      label: String) throws -> TLSIdentity
  • Imports and creates a identity from the given PKCS12 Data. The imported identity will be stored in the Keychain with the given label.

    Declaration

    Swift

    public static func importIdentity(withData data: Data,
                                      password: String?,
                                      label: String) throws -> TLSIdentity
  • Delete the identity in the Keychain with the given label.

    Declaration

    Swift

    public static func deleteIdentity(withLabel label: String) throws