Exports one or more certificates, keys, or identities.
Deprecated
Use Sec
instead.
SDK
- macOS 10.0–10.7Deprecated
Framework
- Security
Declaration
OSStatus SecKeychainItemExport(CFType Ref keychainItemOrArray, Sec External Format outputFormat, Sec Item Import Export Flags flags, const Sec Key Import Export Parameters *keyParams, CFData Ref _Nullable *exportedData);
Parameters
keychainItemOrArray
The keychain item or items to export. You can export only the following types of keychain items:
Sec
,Certificate Ref Sec
, andKey Ref Sec
. If you are exporting exactly one item, you can specify aIdentity Ref Sec
object. Otherwise this parameter is aKeychain Item Ref CFArray
object containing a number of items of typeRef Sec
.Keychain Item Ref outputFormat
The format of the desired external representation for the item. Set this parameter to
k
to use the default for that item type. Possible values for this parameter and default values are enumerated inSec Format Unknown Sec
.External Format flags
A flag indicating whether the exported item should have PEM armor. PEM armor refers to a way of expressing binary data as an ASCII string so that it can be transferred over text-only channels such as email. Set this flag to
k
if you want PEM armoring.Sec Item Pem Armour keyParams
A pointer to a structure containing a set of input parameters for the function. If no key items are being exported, these parameters are optional and you can set the
key
parameter toParams NULL
.exportedData
On return, points to the external representation of the keychain item or items.
Return Value
A result code. See Security Framework Result Codes.
Discussion
This function works only with keys, certificates, and identities. An identity is the combination of a certificate and its associated private key. Although public keys are commonly stored in certificates, they can be stored separately in the keychain as well; for example, when you call the Sec
function to create a key pair, both the public and private keys are stored in the keychain. Use the Sec
function to find a key or certificate. Use the Sec
function in the Certificate, Key, and Trust API to find an identity.
Special Considerations
This function is deprecated in macOS 10.7 and later; use Sec
instead.