Sample code for 30+ languages & platforms
Objective-C

Load PFX/P12 from a Base64 Encoded PFX File

See more PFX/P12 Examples

Demonstrates how to call LoadPfxEncoded.

Chilkat Objective-C Downloads

Objective-C
#import <CkoBinData.h>
#import <NSString.h>
#import <CkoPfx.h>

BOOL success = NO;

CkoBinData *bd = [[CkoBinData alloc] init];

success = [bd LoadFile: @"qa_data/pfx/cert_test123.pfx"];
if (success != YES) {
    NSLog(@"%@",@"Failed to load PFX file.");
    return;
}

// Get the bytes contained in the PFX in base64 format:
NSString *strBase64 = [bd GetEncoded: @"base64"];

// The base64 looks like this:  "MIIbEAIBAzCCGswGCSqGSIb3DQEHAaCCGr0Eghq5MIIatTCCBg..."
NSLog(@"%@",strBase64);

CkoPfx *pfx = [[CkoPfx alloc] init];

// Load the PFX from the base64 string
NSString *password = @"test123";
success = [pfx LoadPfxEncoded: strBase64 encoding: @"base64" password: password];
if (success != YES) {
    NSLog(@"%@",pfx.LastErrorText);
    return;
}

NSLog(@"%@",@"success");