Contents

SecKeychainSearchCreateFromAttributes

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

Declaration

OSStatus SecKeychainSearchCreateFromAttributes(CFTypeRef keychainOrArray, SecItemClass itemClass, const SecKeychainAttributeList *attrList, SecKeychainSearchRef*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. 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. 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.