Most applications do not need to lock and unlock keychains, since most Keychain Manager functions automatically do so if necessary. However, if you are calling low-level functions that manipulate items in a keychain like
KCAddItem
,
KCDeleteItem
,
KCUpdateItem
, and
KCCopyItem
, you are responsible for unlocking the keychain. In this case, you should call the function
KCUnlock
, which displays a dialog box that prompts the user to enter their passphrase to unlock the keychain. If you do not specify a keychain to unlock,
KCUnlock
will automatically unlock the default keychain. If there is no default keychain, it will unlock the last keychain to have been unlocked.When you wish to lock an unlocked keychain, call the function
KCLock
.