Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
PFX to PEM (Certificate and Private Key Files)Export a certificate and private key from a PFX to a pair of PEM files. Downloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries FreeBSD C++ Libraries HP-UX C++ Libraries BlackBerry QNX C++ Libraries #include <C_CkCertStore.h> #include <C_CkCert.h> #include <C_CkPrivateKey.h> void ChilkatSample(void) { BOOL success; HCkCertStore certStore; const char * password; HCkCert cert; HCkPrivateKey pvkey; certStore = CkCertStore_Create(); // Load the PFX file into a certificate store object password = "myPassword"; success = CkCertStore_LoadPfxFile(certStore,"chilkat.pfx",password); if (success != TRUE) { printf("%s\n",CkCertStore_lastErrorText(certStore)); return; } // Find the cert to be exported by the subject: cert = CkCertStore_FindCertBySubject(certStore,"Chilkat Software, Inc."); if (cert == 0 ) { printf("Certificate not found.\n"); return; } // Does this cert have a private key? if (CkCert_HasPrivateKey(cert) == TRUE) { // Get the private key. pvkey = CkCert_ExportPrivateKey(cert); // Export the private key to a PEM file: success = CkPrivateKey_SaveRsaPemFile(pvkey,"chilkat_pkey.pem"); if (success != TRUE) { printf("%s\n",CkPrivateKey_lastErrorText(pvkey)); return; } CkPrivateKey_Dispose(pvkey); } // Save the cert to a PEM file: success = CkCert_ExportCertPemFile(cert,"chilkat_cert.pem"); if (success != TRUE) { printf("%s\n",CkCert_lastErrorText(cert)); return; } CkCert_Dispose(cert); CkCertStore_Dispose(certStore); } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.