Keychain

Also known as: Keychain Access

On this page 7

Keychain is the encrypted credential store built into macOS that holds passwords, cryptographic keys, certificates and secure notes for the user and the system, and releases each item only to authorized apps and processes. In macOS security & privacy, it is the central place where apps keep secrets instead of writing them to their own files, and users manage it through the Keychain Access app or the newer Passwords app.

Keychain lets macOS fill in Wi-Fi passwords, website logins, mail accounts and VPN credentials without asking the user each time, while keeping those secrets encrypted at rest and tied to the user’s login.

How Keychain stores and protects secrets

Keychain stores each secret as an item with attributes and encrypted data. The attributes, such as account name, server and label, help apps find the item, while the secret itself stays encrypted with keys derived from the user’s login password and, on modern Macs, protected by the Secure Enclave.

Item typeContentsTypical user
Internet passwordWebsite or server credentials with protocol and hostSafari, Mail, network clients
Generic passwordAny secret an app stores under a service nameThird-party apps, Wi-Fi networks
CertificatePublic certificate, often a trusted root or client identityTLS, VPN, code signing
KeyPrivate, public or symmetric cryptographic keySigning and encryption
Secure noteFree text stored encryptedUsers storing short secrets
Main types of Keychain items

Access is controlled per item. When an app requests an item it did not create, macOS shows a prompt where the user can allow once, always allow or deny. Choosing always allow adds the app to the item’s access control list, which is why careless approval of prompts weakens the model.

Keychains on a Mac and where they live

A Mac holds several keychains with different owners and lifetimes. Knowing which keychain holds an item explains many troubleshooting cases.

KeychainScopeUnlocked by
Login keychainPer-user secrets in a file-based keychainThe user’s login password
Local Items or iCloud keychainData protection keychain, optionally syncedLogin and device keys
System keychainMachine-wide items such as Wi-Fi for all usersAdministrator authorization
System RootsTrusted root certificates shipped with macOSRead-only, managed by Apple
Standard keychains in macOS

The login keychain file sits in the user’s ~/Library/Keychains folder, while the data protection keychain is managed by the system and uses access groups and app entitlements rather than per-item lists. Apps built for current macOS versions are expected to use the data protection keychain, which follows the same model as iPhone and iPad.

Keychain is often confused with iCloud Keychain and with disk encryption. The features complement each other but protect different things.

FeatureWhat it protectsRelationship to Keychain
KeychainIndividual secrets on the MacThe local store itself
iCloud KeychainSelected secrets across Apple devicesEnd-to-end encrypted sync of the data protection keychain
Passwords appUser-facing view of passwords and passkeysFront end for keychain data
FileVaultThe whole startup diskProtects keychain files when the Mac is off
Secure EnclaveHardware keysGuards the keys that protect keychain items
Keychain and neighboring security features

Since macOS Sequoia, the Passwords app is the everyday tool for website passwords and passkeys, and Keychain Access has moved to the system utilities folder. Keychain Access remains the tool for certificates, keys and system keychain items.

Administration from the command line

Administrators and developers manage keychains with the built-in security command-line tool. It is essential for automation, build servers and scripts that need credentials without storing them in plain text.

  • security find-generic-password -s service -w returns a stored secret to a script, triggering an access prompt if needed.
  • security add-generic-password creates an item, and the -T option lists trusted applications for its access control list.
  • security list-keychains and security unlock-keychain manage the keychain search list on build machines.
  • security add-trusted-cert installs a certificate with specific trust settings, often handled by device management profiles instead.

In managed fleets, certificates and Wi-Fi credentials are usually deployed through configuration profiles from an MDM server, which place items in the correct keychain without user interaction.

Common problems and pitfalls

The most frequent issue is a keychain password mismatch after an administrator resets a user’s login password. The old login keychain stays locked with the previous password, so macOS repeatedly asks for it until the user enters the old password or creates a new login keychain and loses the stored items.

SymptomLikely causeFix
Repeated login keychain promptsKeychain password differs from new login passwordEnter the old password or reset the keychain
App asks for access after every updateNew app signature not in the access listApprove once or reinstall a properly signed version
Certificate shown as not trustedMissing intermediate or trust settingInstall the chain and review trust settings
Passwords missing on another deviceItem stored in the local login keychainSave it again in the synced keychain
Typical Keychain symptoms and fixes

Other pitfalls include granting always allow to unknown apps, exporting identities with weak export passwords, and deleting the login keychain while troubleshooting without a backup. Malware that targets macOS often tries to trick users into approving keychain prompts, so an unexpected request deserves scrutiny.

A plain-language summary

Keychain is the Mac’s built-in safe for passwords and digital keys. When a user saves a Wi-Fi password or a website login, the Mac puts it in this safe.

The safe opens with the user’s login password. Apps must ask before taking anything out, and the Mac shows a prompt when an app wants something it did not put there. That way secrets stay locked away from other apps and from anyone without the password.

An example from practice

A mobile development team runs automated builds on a dedicated Mac mini. Each build must sign the app with a code signing identity, a certificate and private key, and upload it using an API key that must never appear in the build scripts.

The engineer creates a separate build keychain, imports the signing identity into it and stores the API key as a generic password with the security tool, listing only the code signing and upload tools as trusted applications. The build script unlocks this keychain at the start of each job and locks it again at the end.

Builds now run unattended without secrets in the repository. When a contractor leaves, the team rotates the API key in one place, and a stolen copy of the scripts reveals no credentials at all.