SecPKCS12Import

Function SecPKCS12Import 

Source
pub unsafe extern "C-unwind" fn SecPKCS12Import(
    pkcs12_data: &CFData,
    options: &CFDictionary,
    items: NonNull<*const CFArray>,
) -> i32
Available on crate feature SecImportExport only.
Expand description

Imports the contents of a PKCS12 formatted blob.

Parameter pkcs12_data: The PKCS#12 formatted data to be imported.

Parameter options: A dictionary containing import options. A kSecImportExportPassphrase entry is required at minimum. Only password-based PKCS12 blobs are currently supported.

Parameter items: On return, an array containing a dictionary for every item extracted. Use kSecImportItem constants to access specific elements of these dictionaries. Your code must CFRelease the array when it is no longer needed.

Returns: errSecSuccess in case of success. errSecDecode means either the blob can’t be read or it is malformed. errSecAuthFailed means an incorrect password was supplied, or data in the container is damaged.

The normal behavior of this function is to import items into process memory on iOS, and into the default keychain on macOS. You can modify this behavior with entries in the options dictionary. To specify a file-based keychain and legacy access control on macOS, provide kSecImportExportKeychain with a SecKeychainRef value, and/or kSecImportExportAccess with a SecAccessRef value. In macOS 14 and later, it is possible to specify the data protection keychain instead of a file-based keychain by including kSecUseDataProtectionKeychain with a value of kCFBooleanTrue. Starting with macOS 15 and iOS 18, kSecImportToMemoryOnly (with a value of kCFBooleanTrue) allows you to skip importing to the keychain on macOS and explicitly specify iOS behavior.

§Safety

  • options generics must be of the correct type.
  • items must be a valid pointer.