如何指定在钥匙串授权对话框中使用的图标
我使用 SecKeychainFindGenericPassword()
获取之前使用 SecKeychainAddGenericPassword()
保存的应用程序密码。正如预期的那样,MacOS 向用户提供一个对话框,要求他们批准钥匙串访问。但是,叠加在挂锁右下角的图标是通用文档图标,而不是我的应用程序的图标。
我在钥匙串服务参考中看不到任何有关指定图标的内容,因此我假设操作系统仅使用您的应用程序图标。我的 .icns 文件(在 info.plist 中引用)具有根据 Iconographer 填充的所有可能的大小和位图,所以我真的不确定下一步该看哪里。
希望有人能指出我明显的问题吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这通常是因为您的应用程序正在从其他用户无法读取的目录运行。身份验证对话框显然在另一个进程中运行,它需要能够从包中获取您的图标。
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.
正如 Chris Suter 之前提到的,这是一个访问权问题。
plist 中的图标名称与应用程序包 Info.plist 中指向的文件无关,将在提升过程中使用 (CFBundleIconFile)(如果未为电梯指定自定义文件)
在 Lion 或更新的操作系统上尝试一下,您会发现您在家中复制的任何应用程序都受到保护,不受外界攻击(根本无法访问),因此电梯无法读取图标。
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.
在弃用
kSecCustomIconItemAttr
之前,钥匙串服务参考 (2003) 有这样说:也许尝试设置 kSecCreatorItemAttr 和 kSecTypeItemAttr 属性。
Prior to the deprecation of
kSecCustomIconItemAttr
, the Keychain Services Reference (2003) had this to say:Perhaps try setting the
kSecCreatorItemAttr
andkSecTypeItemAttr
attributes.