(Objective-C) Load Certificate from .cer and Private Key from .pem
Load a certificate from a .cer and its associated private key from a .pem.
#import <CkoCert.h>
#import <CkoStringBuilder.h>
CkoCert *cert = [[CkoCert alloc] init];
BOOL success = [cert LoadFromFile: @"C:/certs_and_keys/Certificate.cer"];
if (success == NO) {
NSLog(@"%@",cert.LastErrorText);
return;
}
CkoStringBuilder *sbPem = [[CkoStringBuilder alloc] init];
success = [sbPem LoadFile: @"C:/certs_and_keys/PrivateKey.pem" charset: @"utf-8"];
if (success == NO) {
NSLog(@"%@",@"Failed to load private key PEM");
return;
}
success = [cert SetPrivateKeyPem: [sbPem GetAsString]];
if (success == NO) {
NSLog(@"%@",cert.LastErrorText);
return;
}
NSLog(@"%@",@"The certificate and associated private key are now loaded and ready for signing.");
|