在一個簡單的方法來刪除CN的Certs(證書先前已由SecItemAdd從PKCS12導入);我得到的錯誤:ios/SecItemDelete不接受一個SecIdentityRef/kSecMatchItemList
Property list invalid for format: 200 (property lists cannot contain objects of type 'SecIdentity')
To delete an item identified by a transient reference, specify the kSecMatchItemList search key with a reference returned by using the kSecReturnRef return type key in a previous call to the SecItemCopyMatching or SecItemAdd functions.
信。下面的代碼:
NSDictionary * attributes;
NSString * cnString = @"/CN=foo";
attributes = [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge id)(kSecClassIdentity), kSecClass,
cnString, kSecMatchSubjectContains,
kSecMatchLimitAll, kSecMatchLimit,
kCFBooleanTrue, kSecReturnRef,
nil];
CFArrayRef result;
status = SecItemCopyMatching((__bridge CFDictionaryRef)(attributes),
(CFTypeRef *)&result);
if (status == noErr) {
for(int i = 0; i < CFArrayGetCount(result); i++) {
SecIdentityRef item = (SecIdentityRef) CFArrayGetValueAtIndex(result, i);
NSLog(@"Item #%d: %@", i, item);
attributes = [NSDictionary dictionaryWithObjectsAndKeys:
(__bridge id)(kSecClassIdentity), kSecClass,
[NSArray arrayWithObject:(__bridge id)item], kSecMatchItemList,
kSecMatchLimitOne, kSecMatchLimit,
nil];
status = SecItemDelete((__bridge CFDictionaryRef)(attributes));
if (status != noErr || status != errSecItemNotFound)
NSLog(@"Delete %d/%@failed: %ld (ignored)", i,item, status);
};
};
在控制檯上的輸出是:
Item #0: <SecIdentityRef: 0xc7359ff0>
查找直後(如果搜索是擴大我們得到的這些數組)。
然後從內心深處Security.dylib:
Property list invalid for format: 200 (property lists cannot contain objects of type 'SecIdentity')
最終保釋:
Delete 0/<SecIdentityRef: 0xc7359ff0>failed: -50 (ignored)
我在做什麼錯?
謝謝,
Dw。
我的iOS 6.1.3和iOS 7.1下獲得這個同樣的失敗。 「SecItemDelete」對於匹配項目列表是否仍能正常工作? – Greg