I've got an application that also configures and runs a daemon. I am trying to give both the daemon and the application access permissions to the keychain item. The basic code:
SecKeychainItemRef item; // create a generic password item SecTrustedApplicationRef appRef[2]; SecAccessRef ref; SecTrustedApplicationCreateFromPath( NULL, &appRef[0] ); SecTrustedApplicationCreateFromPath( DAEMON_PATH, &appRef[1] ); CFArrayRef trustList = CFArrayCreate( NULL, ( void *)appRef, sizeof(appRef)/sizeof(*appRef), NULL ); SecAccessCreate( descriptor, trustList, &ref ); SecKeychainItemSetAccess( item, ref );
The keychain entry is created, however the only application listed in the Keychain Access tool as always having access is the main application. Let's call it FOO.app. DAEMON_PATH points to the absolute path of the daemon which is in the application bundle -- call it FOO.daemon
.
If I manually go within Keychain Access and select the daemon, it does get added to the list.
Any idea on how to get SecTrustedApplicationCreateFromPath
to honor the full/absolute path?