<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.0.0 - 10.7.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecKeychainSearchCreateFromAttributes",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecKeychainSearchCreateFromAttributes"
  },
  "title" : "SecKeychainSearchCreateFromAttributes"
}
-->

# SecKeychainSearchCreateFromAttributes

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

```
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(_:)`](/documentation/Security/SecKeychainCopySearchList(_:)) to retrieve the user’s default search list.

`itemClass`

The keychain item class. See [`SecItemClass`](/documentation/Security/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 <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease> function to release this object when you are finished using it.

## Return Value

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes).

## Discussion

> Important:
> This function is deprecated.
> Use ``doc://com.apple.security/documentation/Security/SecItemCopyMatching(_:_:)`` instead.

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`](/documentation/Security/SecKeychainSearchCopyNext) function to find a keychain item and the [`SecKeychainItemCopyAttributesAndData(_:_:_:_:_:_:)`](/documentation/Security/SecKeychainItemCopyAttributesAndData(_:_:_:_:_:_:)) function to retrieve the item’s data.

To find and obtain data from a password keychain item, use the [`SecKeychainFindInternetPassword(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)`](/documentation/Security/SecKeychainFindInternetPassword(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)) or [`SecKeychainFindGenericPassword(_:_:_:_:_:_:_:_:)`](/documentation/Security/SecKeychainFindGenericPassword(_:_:_:_:_:_:_:_:)) function.

---

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)