Function

SecKeychainGetStatus

Retrieves status information of a keychain.

Declaration

OSStatus SecKeychainGetStatus(SecKeychainRef keychain, SecKeychainStatus *keychainStatus);

Parameters

keychain

A keychain object of the keychain whose status you wish to determine for the user session. Pass NULL to obtain the status of the default keychain.

keychainStatus

On return, a pointer to the status of the specified keychain. See SecKeychainStatus for valid status constants.

Return Value

A result code. See Security Framework Result Codes. The result code errSecNoSuchKeychain indicates that the specified keychain could not be found. The result code errSecInvalidKeychain indicates that the specified keychain is invalid.

Discussion

This function retrieves the status of a specified keychain. You can use this function to determine if the keychain is unlocked, readable, or writable. Note that the lock status of a keychain can change at any time due to user or system activity. Because the system automatically prompts the user to unlock a keychain when necessary, you do not usually have to worry about the lock status of a keychain. If you do need to track the lock status of a keychain, use the SecKeychainAddCallback function to register for keychain notifications.

See Also

Keychain Management

SecKeychainGetVersion

Determines the version of keychain services installed on the user’s system.

SecKeychainOpen

Opens a keychain.

SecKeychainSetDefault

Sets the default keychain.

SecKeychainCopyDefault

Retrieves a pointer to the default keychain.

SecKeychainGetPath

Determines the path of a keychain.

SecKeychainStatus

A value that defines the current status of a keychain.

SecKeychainStatus Values

Valid values for the keychain status type.