Beny
Beny

Reputation: 900

Using a certificate from Keychain in a Mac application

I am trying to build a mini-application to codesign one Mac OS X application with codesign utility and my developer certificate in keychain. To do that I use NSTask, like that :

[task setLaunchPath:@"/usr/bin/codesign"];
// ...
NSString *certificateName = @"\"3rd Party Mac Developer Application: Firstname Lastname\"";
NSString *appName = @"\"/path/to/My App.app\"";
NSArray *args = [NSArray arrayWithObjects:@"-s", certificateName, appName, nil];
// ...
[task launch];

I use a NSPipe to catch the output and I got this error message : no identity found...
But if I launch this command manually via Terminal, the application is well signed (so it's not a problem of certificate badly installed, etc).

I think issue comes because my application can't access the certificate in keychain (but me I can via Terminal).

Does someone already experienced this problem ?

Thanks in advance, Best.

Upvotes: 2

Views: 408

Answers (1)

Martin R
Martin R

Reputation: 539685

You should not embed additional quotation marks in the arguments to NSTask:

NSString *certificateName = @"3rd Party Mac Developer Application: Firstname Lastname";
NSString *appName = @"/path/to/My App.app";

Spaces in the arguments are handled automatically, and do not require quotation marks.

Upvotes: 2

Related Questions