Unicode C
Unicode C
Load a PFX from an Encoded String
See more PFX/P12 Examples
Demonstrates Pfx.LoadPfxEncoded, which decodes text using a named binary encoding (such as base64) and loads the resulting bytes as a PFX / PKCS#12 container.
Background. This is useful when the PKCS#12 data has been transported or stored as printable text, such as base64.
Chilkat Unicode C Downloads
#include <C_CkPfxW.h>
void ChilkatSample(void)
{
BOOL success;
HCkPfxW pfx;
const wchar_t *password;
const wchar_t *encodedPfx;
success = FALSE;
pfx = CkPfxW_Create();
// The PFX password should come from a secure source rather than being hard-coded.
password = L"myPfxPassword";
// Decode the base64 text into PFX / PKCS#12 bytes and load them. Common encodings include base64
// and hex.
encodedPfx = L"MIIKrAIBAzCCCm...base64-encoded-pfx...";
success = CkPfxW_LoadPfxEncoded(pfx,encodedPfx,L"base64",password);
if (success == FALSE) {
wprintf(L"%s\n",CkPfxW_lastErrorText(pfx));
CkPfxW_Dispose(pfx);
return;
}
wprintf(L"Loaded %d certificate(s).\n",CkPfxW_getNumCerts(pfx));
CkPfxW_Dispose(pfx);
}