2013-03-05 42 views
3

我知道有SecPKCS12Import API來導入(解析)PKCS12。如何在目標C中創建PKCS12

如何從SecIdentityRef + SecCertificateRef創建PKCS12?

我正在尋找一種方法來使用本機API(安全框架),而不是整合OpenSSL(或其他第三方庫)。

回答

1

您正在尋找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 */ 
} 
0

此外,還有SecKeychainItemExport API,它由SecItemExport在內部使用。