CredentialProtocol

public protocol CredentialProtocol : AnyObject, 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.

  • 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

    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

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

    Declaration

    Swift

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

    Declaration

    Swift

    func type() -> CredentialType