Function

SecKeychainSearchCreateFromAttributes

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

Declaration

OSStatus SecKeychainSearchCreateFromAttributes(CFTypeRef keychainOrArray, SecItemClass itemClass, const SecKeychainAttributeList *attrList, SecKeychainSearchRef  _Nullable *searchRef);

Parameters

keychainOrArray

A reference to an array of keychains to search, a single keychain, or NULL to search the user’s current keychain search list. Use the function SecKeychainCopySearchList to retrieve the user’s default search list.

itemClass

The keychain item class. See SecItemClass for valid constants.

attrList

A pointer to a list of zero or more keychain attribute records to match. Pass NULL to match any keychain attribute.

searchRef

On return, a pointer to the current search object. 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. You look up an item in a keychain by its attributes. If you find a match, you can then retrieve the item’s data. Use the search object created by this function as input to the SecKeychainSearchCopyNext function to find a keychain item and the SecKeychainItemCopyAttributesAndData function to retrieve the item’s data.

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
SecKeychainSearchCopyNext

Finds the next keychain item matching the given search criteria.

Deprecated