Deletes one or more keychains from the default keychain search list, and removes the keychain itself if it is a file.


OSStatus SecKeychainDelete(SecKeychainRef keychainOrArray);



A single keychain object or a reference to an array of keychains you wish to delete. To delete more than one keychain, create a CFArray of keychain references (type SecKeychainRef) and pass a reference to the array.

In macOS 10.3 and later, passing NULL to this parameter returns an errSecInvalidKeychain error code. In OS X 10.2, this parameter was named keychain and only took a single keychain object. Passing NULL to this parameter deleted the user’s default keychain.

Return Value

A result code. See Security Framework Result Codes. The result code errSecInvalidKeychain is returned if the specified keychain is invalid or if the value of the keychainOrArray parameter is invalid or NULL.


The keychain may be a file stored locally, a smart card, or retrieved from a network server using non-file-based database protocols. This function deletes the keychain only if it is a local file.

This function does not release the memory used by the keychain object; you must call the CFRelease function to release each keychain object when you are finished with it.

See Also

Creation and Deletion


Creates an empty keychain.


An opaque type that represents a keychain.


Returns the unique identifier of the opaque type to which a keychain object belongs.