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

# SecPKCS12Import(_:_:_:)

Returns the identities and certificates in a PKCS #12-formatted blob.

```
func SecPKCS12Import(_ pkcs12_data: CFData, _ options: CFDictionary, _ items: UnsafeMutablePointer<CFArray?>) -> OSStatus
```

## Parameters

`pkcs12_data`

The PKCS #12 data you wish to decode.

`options`

A dictionary of key-value pairs specifying options for the function. See [Keychain Import and Export Options](/documentation/Security/keychain-import-and-export-options) for a list of valid keys.

`items`

On return, an array of `CFDictionary` key-value dictionaries. The function returns one dictionary for each item (identity or certificate) in the PKCS #12 blob. For a list of dictionary keys, see [PKCS #12 Import Item Keys](/documentation/Security/pkcs-12-import-item-keys).

## Return Value

A result code. See [Security Framework Result Codes](/documentation/Security/security-framework-result-codes). The function returns [`errSecSuccess`](/documentation/Security/errSecSuccess) if there were no errors, [`errSecDecode`](/documentation/Security/errSecDecode) if the blob can’t be read or is malformed, and [`errSecAuthFailed`](/documentation/Security/errSecAuthFailed) if the password was not correct or data in the blob was damaged.

## Discussion

Your application can import a PKCS #12–formatted blob (a file with extension `.p12`) containing certificates and identities, where an identity is a digital certificate together with its associated private key. You can use the `SecPKCS12Import` function to obtain `SecIdentityRef` objects (including `SecCertificateRef` and `SecKeyRef` objects) for the identities in the blob, together with `SecCertificateRef` objects for the certificates in the blob needed to validate the identity, and `SecTrustRef` trust management objects needed to evaluate trust for the identities. You can then use the Keychain Services API (see [Keychain services](/documentation/Security/keychain-services)) to put the identities and associated certificates in the keychain.

---

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)