简体   繁体   中英

How do I specify the icon to use in the Keychain authorisation dialog

I'm using SecKeychainFindGenericPassword() to get an application password that I have previously saved with SecKeychainAddGenericPassword() . As expected, MacOS gives the user a dialog asking them to approve the keychain access. However the icon superimposed over the lower right of the padlock is a generic document icon, not my application's icon.

I can't see anything in the Keychain Services References about specifying the icon, so I would assume that the OS just uses your application icon. My .icns file (referenced in the info.plist) has all possible sizes and bitmaps populated according to Iconographer so I'm really not sure where to look next.

Hoping there is an obvious gotcha that someone can point me to?

This is an access right problem as Chris Suter mention earlier. The name of the icon in the plist is irrelevant the file pointed in the app bundle Info.plist will be used (CFBundleIconFile) in the elevation process (if not specified a custom one to the elevator) Try it on a Lion or newer OS and you will find that any app you copied in your home is protected against the world (that has no access at all) therefore the elevator can not read the icon.

It's usually because your application is running from a directory that isn't readable by other users. The authentication dialog obviously runs in another process and it needs to be able to get your icon from the bundle.

Prior to the deprecation of kSecCustomIconItemAttr , the Keychain Services Reference (2003) had this to say:

kSecCustomIconItemAttr

Identifies the custom icon attribute. You use this tag to set or get a value of type Boolean that indicates whether the item has an application-specific icon. To do this, you must also set the attribute value identified by the tag kSecTypeItemAttr to a file type for which there is a corresponding icon in the desktop database, and set the attribute value identified by the tag kSecCreatorItemAttr to an appropriate application creator type. If a custom icon corresponding to the item's type and creator can be found in the desktop database, it will be displayed by Keychain Access. Otherwise, default icons are used.

Perhaps try setting the kSecCreatorItemAttr and kSecTypeItemAttr attributes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM