Credential

open class Credential : CredentialProtocol, @unchecked Sendable

A cryptographic credential.

This is tied to a particular client via either its client id or certificate bundle, depending on its credential type, but is independent of any client instance or storage.

To attach a credential to a client instance and store it, call add_credential on a CoreCryptoContext.

  • Generate a basic credential.

    The result is independent of any client instance and the database; it lives in memory only.

    Declaration

    Swift

    public static func basic(cipherSuite: CipherSuite, clientId: ClientId) throws -> Credential
  • Get the earliest possible validity of this credential, expressed as seconds after the unix epoch.

    For an X509 credential this is the leaf certificate’s not_before claim. A basic credential has no such claim, and reads as the time it was persisted.

    Declaration

    Swift

    open func earliestValidity() -> UInt64
  • Export a PEM string containing the public portion of this credential.

    • Basic credentials export their public key.
    • x509 credentials export the full certificate chain. This enables external tools such as openssl to validate the certificate chain.

    Declaration

    Swift

    open func exportPem() -> String
  • Get the signature scheme of this credential.

    Declaration

    Swift

    open func signatureScheme() -> SignatureScheme
  • Get the type of this credential.

    Declaration

    Swift

    open func type() -> CredentialType