Contents

SecKeychainSearchCopyNext

Finds the next keychain item matching the given search criteria.

Declaration

OSStatus SecKeychainSearchCopyNext(SecKeychainSearchRef searchRef, SecKeychainItemRef*itemRef);

Parameters

  • searchRef:

    A reference to the current search criteria. The search object is created in the Seckeychainsearchcreatefromattributes function and must be released by calling the CFRelease function when you are done with it.

  • itemRef:

    On return, a pointer to a keychain item object of the next matching keychain item, if any. In Objective-C, call the Cfrelease function to release this object when you are finished using it.

Return Value

A result code. See Security Framework Result Codes.

Discussion

Each item stored in the keychain contains data (such as a certificate), which is indexed by the item’s attributes. Use the SecKeychainSearchCreateFromAttributes function to specify attributes to search for. If the SecKeychainSearchCopyNext function finds a match, you can use the SecKeychainItemCopyAttributesAndData(_:_:_:_:_:_:) function to retrieve the item’s data.

A SecKeychainItem object for a certificate that is stored in a keychain can be safely cast to a SecCertificate for use with the Certificate, Key, and Trust API.

To find and obtain data from a password keychain item, use the SecKeychainFindInternetPassword(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:) or SecKeychainFindGenericPassword(_:_:_:_:_:_:_:_:) function.