- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法让此调用适用于 IOS。我尝试了多种方法,但似乎没有任何效果:我总是获得 errSecParam 状态。谁能告诉我我做错了什么?
我开始使用它来获取我从字节中提取的证书的属性列表。那没有用,所以我将其简化为这个并收到相同的错误。我在模拟器和 iPhone6 上进行了测试,得到了相同的结果。
首先,我获得一组证书,然后将该数组传递回 SecItemCopyMatching。我试过这个,我只查询属性并得到相同的错误。
我是 IOS 的新手,所以我不怀疑这是我错过的东西。
谢谢。
// Call SecItemCopyMatching twice: the first time fetch an array of certificates
// and the second time use the array with kSecMatchItemList.
- (void) SecItemCopyMatchingTest2 {
// Now read them from the keychain.
NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys:
(__bridge id)kSecClassCertificate,(__bridge id)kSecClass,
(__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnRef,
(__bridge id)kSecMatchLimitAll, (__bridge id)kSecMatchLimit,
nil];
CFTypeRef result;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result);
NSArray *rgRefs = CFBridgingRelease(result);
if (status == noErr){
// this works
}
// Use the array we received from our previous call
[query setObject:rgRefs forKey:(__bridge id)kSecMatchItemList];
CFTypeRef result2;
// Results in status = errSecParam
status = SecItemCopyMatching((__bridge CFDictionaryRef)query, &result2);
if (status == errSecParam){
// the cal fails.
}
}
最佳答案
引自头文件文档:
@constant
kSecMatchItemList
OS X only. Specifies a dictionary key whose value is a CFArray of SecKeychainItemRef items. If provided, returned items will be limited to the subset which are contained in this list.
我知道 __OSX_AVAILABLE_STARTING
声称它存在于 iOS,但这是一个谎言,在邮件列表中,一位 Apple 开发人员声称它从未为 iOS 实现。
尝试使用 kSecUseItemList
设置相同的数组。根据邮件列表,这在当时也没有为 iOS 实现,但如果 Apple 打算为 iOS 实现其中一个(或已经这样做),那么它就是 kSecUseItemList
。
macOS 和 iOS 之间存在许多奇怪的钥匙串(keychain) API 差异,其中一些差异仅存在于文档或头文件中。这是 SecItemDelete()
删除文档中的另一个示例:
To delete an item identified by a transient reference, on iOS, specify kSecValueRef with a item reference. On OS X, give a kSecMatchItemList containing an item reference.
尝试在 iOS 上使用 kSecMatchItemList
会失败,就像在 macOS 上使用 kSecValueRef
似乎会失败一样。这些 API 差异对我来说没有任何意义,但要么你可以使用 kSecUseItemList
来完成,要么你运气不好,这在 iOS 上根本不可能。
关于ios - SecItemCopyMatching 与 kSecMatchItemList 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30448481/
我无法让此调用适用于 IOS。我尝试了多种方法,但似乎没有任何效果:我总是获得 errSecParam 状态。谁能告诉我我做错了什么? 我开始使用它来获取我从字节中提取的证书的属性列表。那没有用,所以
通过 CN 删除证书的简单方法(证书之前已由 SecItemAdd 从 PKCS12 导入中放置在那里);我收到错误: Property list invalid for format: 200 (p
我是一名优秀的程序员,十分优秀!