<!--
{
  "availability" : [
    "macOS: 10.2.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecKeychainGetStatus(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecKeychainGetStatus"
  },
  "title" : "SecKeychainGetStatus(_:_:)"
}
-->

# SecKeychainGetStatus(_:_:)

Retrieves status information of a keychain.

```
func SecKeychainGetStatus(_ keychain: SecKeychain?, _ keychainStatus: UnsafeMutablePointer<SecKeychainStatus>) -> OSStatus
```

## 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`](/documentation/Security/SecKeychainStatus) for valid status constants.

## Return Value

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes). The result code [`errSecNoSuchKeychain`](/documentation/Security/errSecNoSuchKeychain) indicates that the specified keychain could not be found. The result code [`errSecInvalidKeychain`](/documentation/Security/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(_:_:_:)`](/documentation/Security/SecKeychainAddCallback(_:_:_:)) function to register for keychain notifications.

---

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)