gpt4 book ai didi

iOS Keychain 写入值导致错误代码 -34018

转载 作者:IT王子 更新时间:2023-10-29 07:56:45 24 4
gpt4 key购买 nike

我有一个 iOS 应用程序,它在钥匙串(keychain)中存储了一些敏感信息。将值写入钥匙串(keychain)时,出现错误代码 -34018。

我目前正在使用 Apple 的 iOS KeyChainItemWrapper 类。

以下两行代码收到相同的错误代码。

OSStatus res1 = SecItemCopyMatching((__bridge CFDictionaryRef)genericPasswordQuery, (CFTypeRef *)&attributes);
OSStatus res = SecItemUpdate((__bridge CFDictionaryRef)updateItem, (__bridge CFDictionaryRef)tempCheck);

这个问题不是每次都会出现,而是间歇性出现。一旦出现此错误,我就无法再向钥匙串(keychain)写入任何值。

我已经像这样打印了错误描述:

NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:res userInfo:nil];

这是错误打印出来的内容:

Error: Error Domain=NSOSStatusErrorDomain Code=-34018 "The operation couldn’t be completed. (OSStatus error -34018.)"

最佳答案

这似乎是 Keychain 中的一个错误,只有当您从 xcode 启动您的应用程序时才会出现。看这里:https://github.com/soffes/sskeychain/issues/52

We debugged it a lot and it seems an issue accessing the keychain when the app is launched from the background. This is only happening with the debugger (i.e. when launched from Xcode). We think the issue might be related in our case to the debugger keeping alive the app even if it should be killed by the OS. We tried in fact to run the app and then put it in background and launch many other app to occupy RAM. With the debugger the bug came up when resuming the app from the background, while without the debugger it didn't (we did run at least 10 tests each).

关于iOS Keychain 写入值导致错误代码 -34018,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27752444/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com