gpt4 book ai didi

ios - OSStatus 错误代码 -34018

转载 作者:IT老高 更新时间:2023-10-28 11:37:12 25 4
gpt4 key购买 nike

我正在使用 SecItemCopyMatching 来访问 iOS 钥匙串(keychain)。从后台重新启动应用程序后,我大约有一百分之一得到 -34018 结果代码。 The documentation状态:

The assigned error space for Keychain Services is discontinuous: –25240 through –25279 and –25290 through –25329. Keychain Item Services may also return noErr (0) or paramErr (–50), or CSSM result codes

所以看来 -34018 是一个'CSSM结果代码'。我关注了suggested link但找不到结果代码。

-34018 结果码是什么?如何获得更可靠的钥匙串(keychain)访问?

- (NSData *)getKeychainData:(NSString *)key
{
NSDictionary *query = @{
(__bridge id)kSecClass:(__bridge id)kSecClassGenericPassword,
(__bridge id)kSecAttrService:SEC_ATTR_SERVICE,
(__bridge id)kSecAttrAccount:key,
(__bridge id)kSecReturnData:@YES
};

CFDataRef result = nil;

OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&result);

if(status == errSecItemNotFound) {
return nil;
}

if(status == noErr) {
return CFBridgingRelease(result);
} else {
[self logError:[NSString stringWithFormat:@"SecItemCopyMatching status %d", (int)status] :nil];
return nil;
}
}

最佳答案

经过一番研究,我发现:http://opensource.apple.com/source/Security/Security-55471/sec/Security/SecBasePriv.h

所以 -34018errSecMissingEntitlement 并且评论说

Internal error when a required entitlement isn't present.

您在运行单元测试时是否遇到此错误?如果是这样,这可能会有所帮助:https://stackoverflow.com/a/22305193/171933

github 上的这个问题说它似乎只在从 Xcode 调试时发生:https://github.com/soffes/sskeychain/issues/97 (另见 https://stackoverflow.com/a/28256591/171933)

希望这会有所帮助!

关于ios - OSStatus 错误代码 -34018,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29740952/

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