为什么SFHFKeychainUtils在Cocoa应用程序中失败并出现错误errSecAuthFailed?

时间:2012-06-19 18:42:15

标签: objective-c cocoa sfhfkeychainutils

使用SFHFKeychainUtils的一些代码的调试版本在我正在开发的mac上工作时没有抱怨是在另一个mac上触发错误:

该代码使用SFHFKeychainUtils提供的以下方法:

+[SFHFKeychainUtils getPasswordForUsername:andServiceName:accessGroup:error:]

+[SFHFKeychainUtils storeUsername:andPassword:forServiceName:accessGroup:updateExisting:updateExisting:error:]

使用+[SFHFKeychainUtils storeUsername:andPassword:forServiceName:accessGroup:updateExisting:updateExisting:error:]为用户名添加密码。一段时间后,尝试使用+[SFHFKeychainUtils getPasswordForUsername:andServiceName:accessGroup:error:]检索密码。但是,此方法返回错误;其域名为SFHFKeychainUtilsErrorDomain,其代码为-25293(因此为errSecAuthFailed)。只有当密码实际存储在钥匙串中时(或者至少从钥匙串访问中可见),才会返回此错误。

为什么会这样?

1 个答案:

答案 0 :(得分:4)

问题是缺少代码签名。需要代码签名才能使第二台机器访问钥匙串。修复是为调试版本启用代码签名。

相关问题