hi,
I'm trying to build an iOS app on my iPhone 5S using Xcode 6.1.1, and it's working fine on my iPhone device.
But one of my functions (i'm using chilkat products)from (chilkatsoft.com) requires to load a certificate (.pfx) (which is stored on my desktop), but it cannot open or read the file.
i get an error message "No such file or directory Failed to open file"
the function works as follows:
<pre lang="objc">
- (void)loadClientDigitalCertificateFromPFX:(int)flag
{
CkoCert *cert = [[CkoCert alloc] init];
BOOL success;
// Load from the PFX file
NSString *pfxFilename;
pfxFilename = @"/Users/user/Desktop/Rania.pfx";
NSString *pfxPassword;
pfxPassword = @"**********";
// A PFX typically contains certificates in the chain of authentication.
// The Chilkat cert object will choose the certificate w/
// private key farthest from the root authority cert.
// To access all the certificates in a PFX, use the
// Chilkat certificate store object instead.
success = [cert LoadPfxFile: pfxFilename password: pfxPassword];
if (success != YES) {
NSLog(@"%@",cert.LastErrorText);
NSLog(@"ERROR");
// return;
}
// Get some information about the digital certificate,
// then get the private key...
// DN = "Distinguished Name"
/*NSLog(@"Subject DN: %@",cert.SubjectDN);
NSLog(@"Common Name: %@",cert.SubjectCN);
NSLog(@"Issuer Common Name: %@",cert.IssuerCN);
NSLog(@"Serial Number: %@",cert.SerialNumber);*/
//*********************************************************
if(flag == 1)
// Now get the private key and Export it into an XML format
{
CkoPrivateKey *pkey;
pkey = [cert ExportPrivateKey];
if (pkey == nil ) {
NSLog(@"%@",cert.LastErrorText);
//return;
}
NSString *prvkeyXml;
// Get the private key in XML format:
prvkeyXml = [pkey GetXml];
//NSLog(@"Client Private Key: %@", prvkeyXml);
return prvkeyXml;
}
//********************************************************
else
{
// Get the public key and Export it into XML format
CkoPublicKey *pubkey;
pubkey = [cert ExportPublicKey];
if (pubkey == nil ) {
NSLog(@"%@",cert.LastErrorText);
//return;
}
NSString *pubkeyXml;
pubkeyXml = [pubkey GetXml];
//NSLog(@"Client Public Key: %@", pubkeyXml);
return pubkeyXml;
}
}
//===============================================================================
the following is the error message i get:
2015-02-16 21:46:55.749 newDGCH2[1875:812662] ChilkatLog:
LoadPfxFile:
DllDate: Jan 22 2015
ChilkatVersion: 9.5.0.47
UnlockPrefix: ********
Architecture: Little Endian; 64-bit
Language: IOS Objective-C
VerboseLogging: 0
class: Cert
pfxPath: /Users/user/Desktop/Rania.pfx
loadFileX:
pathQP: /Users/user/Desktop/Rania.pfx
fopen_failed:
errno: 2
osErrorMessage: No such file or directory
Failed to open file.
mode: r
path: /Users/user/Desktop/Rania.pfx
--fopen_failed
Failed to open for read.
--loadFileX
Failed.
--LoadPfxFile
--ChilkatLog
2015-02-16 21:46:55.751 newDGCH2[1875:812662] ChilkatLog:
LoadPfxFile:
DllDate: Jan 22 2015
ChilkatVersion: 9.5.0.47
UnlockPrefix: ********
Architecture: Little Endian; 64-bit
Language: IOS Objective-C
VerboseLogging: 0
class: Cert
pfxPath: /Users/user/Desktop/Rania.pfx
loadFileX:
pathQP: /Users/user/Desktop/Rania.pfx
fopen_failed:
errno: 2
osErrorMessage: No such file or directory
Failed to open file.
mode: r
path: /Users/user/Desktop/Rania.pfx
--fopen_failed
Failed to open for read.
--loadFileX
Failed.
--LoadPfxFile
--ChilkatLog
So, i was wondering what is the problem, can XCode open a certificate from the desktop? OR
do i have to import it from the Keychain Access or what?
i have no clue!!!!!
Can somebody please help me :)
Best Regards.
Rania