Archived Forum Post

Index of archived forum posts

Question:

cannot Save private key as an XML

Mar 08 '15 at 16:50

Hi,

I'v retrieved my certificate and now i'm trying to use the function that saves the private key to various format (in Objective-C) (Xcode) as follows:

CkoPrivateKey *privKey = 0;

privKey = [cert ExportPrivateKey];
if (privKey == nil ) {
    NSLog(@"%@",cert.LastErrorText);
    return;
}

if(privKey)
    NSLog(@"TRUE");
NSLog(@"Private Key: %@", privKey);

//  Export to various formats:

//  XML (unencrypted)
//path = @"/Users/user/Desktop/ChilkatKeys/PrivateKey/chilkat.xml";
success = [privKey SaveXmlFile: @"/Users/user/Desktop/ChilkatKeys/PrivateKey/private_key.xml"];
if (success != YES) {
    NSLog(@"%@",privKey.LastErrorText);

    return;
}

but i get the following error:

2015-03-08 23:33:02.252 CertificateChilkat[3369:1480558] ChilkatLog: SaveXmlFile: DllDate: Jan 22 2015 ChilkatVersion: 9.5.0.47 UnlockPrefix: NONE Architecture: Little Endian; 64-bit Language: IOS Objective-C VerboseLogging: 0 xmlPath: /Users/user/Desktop/ChilkatKeys/PrivateKey/private_key.xml pathQP: /Users/user/Desktop/ChilkatKeys/PrivateKey/private_key.xml fopen_failed: errno: 2 osErrorMessage: No such file or directory Failed to open file. mode: w path: /Users/user/Desktop/ChilkatKeys/PrivateKey/private_key.xml --fopen_failed filename: /Users/user/Desktop/ChilkatKeys/PrivateKey/private_key.xml Failed to write complete file (7) Failed. --SaveXmlFile --ChilkatLog

I don't know whats the problem, even though i've created the path and changed its permission into "Read/Write" Can someone please help me!!!

Best Regards.