Function

SecKeychainSearchCopyNext

Finds the next keychain item matching the given search criteria.

Declaration

OSStatus SecKeychainSearchCopyNext(SecKeychainSearchRef searchRef, SecKeychainItemRef  _Nullable *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. You must call the CFRelease function to release this object when you are finished using it.

Return Value

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 SecKeychainItemRef object for a certificate that is stored in a keychain can be safely cast to a SecCertificateRef 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.

See Also

Search

SecKeychainSetSearchList

Specifies the list of keychains to use in the default keychain search list.

SecKeychainCopySearchList

Retrieves a keychain search list.

SecKeychainSearchRef

An opaque type that contains information about a keychain search.

SecKeychainSearchGetTypeID

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

Deprecated
SecKeychainSearchCreateFromAttributes

Creates a search object matching a list of zero or more attributes.

Deprecated