<!--
{
  "availability" : [
    "macOS: 10.2.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecKeychainCopyDomainDefault(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecKeychainCopyDomainDefault"
  },
  "title" : "SecKeychainCopyDomainDefault(_:_:)"
}
-->

# SecKeychainCopyDomainDefault(_:_:)

Retrieves the default keychain from a specified preference domain.

```
func SecKeychainCopyDomainDefault(_ domain: SecPreferencesDomain, _ keychain: UnsafeMutablePointer<SecKeychain?>) -> OSStatus
```

## Parameters

`domain`

The preference domain from which you wish to retrieve the default keychain. See [`SecPreferencesDomain`](/documentation/Security/SecPreferencesDomain) for possible domain values.

`keychain`

On return, a pointer to the keychain object of the default keychain in the specified preference domain.

## Return Value

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

## Discussion

A preference domain is a set of security-related preferences, such as the default keychain and the current keychain search list. Use this function if you want to retrieve the default keychain for a specific preference domain. Use the [`SecKeychainCopyDefault(_:)`](/documentation/Security/SecKeychainCopyDefault(_:)) function if you want the default keychain for the current preference domain. See the [`SecKeychainSetPreferenceDomain(_:)`](/documentation/Security/SecKeychainSetPreferenceDomain(_:)) function for a discussion of current and default preference domains.

---

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)