<!--
{
  "documentType" : "article",
  "framework" : "Security",
  "identifier" : "/documentation/Security/storing-an-identity-in-the-keychain",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Storing an Identity in the Keychain"
}
-->

# Storing an Identity in the Keychain

Securely store an identity in the keychain.

## Discussion

You store an identity in or retrieve an identity from a keychain much as you would a certificate, as described in [Storing a Certificate in the Keychain](/documentation/Security/storing-a-certificate-in-the-keychain).

Private keys have a one-to-many relationship with certificates. That is, a single private key can be paired with multiple certificates, but a given certificate corresponds to exactly one private key. As a result, the fields that distinguish one identity from another are the same as those of the certificate it contains. As a result, working with identities as keychain items is very much like working with certificates, with a few minor adjustments:

- Use [`SecIdentity`](/documentation/Security/SecIdentity) objects instead of [`SecCertificate`](/documentation/Security/SecCertificate) objects.
- Use [`kSecClassIdentity`](/documentation/Security/kSecClassIdentity) instead of [`kSecClassCertificate`](/documentation/Security/kSecClassCertificate) for the [`kSecClass`](/documentation/Security/kSecClass) attribute.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)