<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.3.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SecIdentityCopyPrivateKey(_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SecIdentityCopyPrivateKey"
  },
  "title" : "SecIdentityCopyPrivateKey(_:_:)"
}
-->

# SecIdentityCopyPrivateKey(_:_:)

Retrieves the private key associated with an identity.

```
func SecIdentityCopyPrivateKey(_ identityRef: SecIdentity, _ privateKeyRef: UnsafeMutablePointer<SecKey?>) -> OSStatus
```

## Parameters

`identityRef`

The identity object for the identity whose private key you wish to retrieve.

`privateKeyRef`

On return, points to the private key object for the specified identity. The private key must be of class type [`SecItemClass.privateKeyItemClass`](/documentation/Security/SecItemClass/privateKeyItemClass). In Objective-C, call the <doc://com.apple.documentation/documentation/CoreFoundation/CFRelease> function to release this object when you are finished with it.

## Return Value

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

## Discussion

An identity is a digital certificate together with its associated private key.

---

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)