Hello,
I'm facing a particularly weird issue where I'm trying to share access to a keychain item for two of my apps. More precisely my app includes a helper app that creates a keychain item it wants to share with the main app.
I've boiled it down to the call to SecTrustedApplicationCreateFromPath(appPath, &trustedAppRef);
If my app (and helper app) are running from the DerivedData folder (when I'm running in Xcode) this call will return errSecCoreFoundationUnknown (-4960) but If I move the app to be inside "/Applications/" everything works correctly. If I move the app to "/User/<username>/Applications/" it fails again with errSecCoreFoundationUnknown...
I tried creating another executable to test this with just the following code:
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSURL *appURL = [NSURL fileURLWithPath:@"/Users/dev/Applications/Secrets.app"];
SecTrustedApplicationRef trustedAppRef = NULL;
char pathBuffer[MAXPATHLEN];
char *finalPath = NULL;
if( CFURLGetFileSystemRepresentation((__bridge CFURLRef)appURL, TRUE, (UInt8 *)pathBuffer, sizeof(pathBuffer)) ){
finalPath = pathBuffer;
}
OSStatus status = SecTrustedApplicationCreateFromPath(finalPath, &trustedAppRef);
NSLog(@"%d", status);
}
return 0;
}
And it works irrespective of where the app is located...
So why is it that my helper app cannot create a SecTrustedApplicationRef when passed a path outside of "/Applications/"?
Thanks,
Paulo