Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create PKCS12 in Objective C

I know there is SecPKCS12Import API to import(parse) PKCS12.

How to create PKCS12 from SecIdentityRef + SecCertificateRef?

I am looking for a way to use native API (Secure framework) rather than integrating OpenSSL (or other 3rd party library).

like image 946
Victor Ronin Avatar asked Dec 12 '25 16:12

Victor Ronin


1 Answers

You're looking for SecItemExport.

CFDataRef exportedData;
OSStatus ret = SecItemExport(arrayWithIdentityAndCert,
                             kSecFormatPKCS12,
                             0, /* Use kSecItemPemArmour to add PEM armor */
                             NULL,
                             &exportedData);

if(ret == errSecSuccess)
{
  /* exportedData now contains your PKCS12 data */
}

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!