(Objective-C) Load PFX/P12 from a Base64 Encoded PFX File
Demonstrates how to call LoadPfxEncoded.
#import <CkoBinData.h>
#import <NSString.h>
#import <CkoPfx.h>
CkoBinData *bd = [[CkoBinData alloc] init];
BOOL 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");
|