Sample code for 30+ languages & platforms
Objective-C

ZATCA Load Certificate and Private Key from PEM Files

See more ZATCA Examples

Demonstrates how to load a certificate and private key from a pair of PEM files.

Chilkat Objective-C Downloads

Objective-C
#import <CkoCert.h>
#import <CkoPrivateKey.h>

BOOL success = NO;

// The LoadFromFile method will automatically detect the file format..
CkoCert *cert = [[CkoCert alloc] init];
success = [cert LoadFromFile: @"qa_data/zatca/cert.pem"];
if (success != YES) {
    NSLog(@"%@",cert.LastErrorText);
    return;
}

NSLog(@"%@",cert.SubjectCN);

// Load the private key.
CkoPrivateKey *privKey = [[CkoPrivateKey alloc] init];
success = [privKey LoadPemFile: @"qa_data/zatca/ec-secp256k1-priv-key.pem"];
if (success != YES) {
    NSLog(@"%@",privKey.LastErrorText);
    return;
}

NSLog(@"%@%@",@"Key Type: ",privKey.KeyType);

// Associate the private key with the certificate.
success = [cert SetPrivateKey: privKey];
if (success != YES) {
    NSLog(@"%@",cert.LastErrorText);
    return;
}

NSLog(@"%@",@"Success.");