キーチェーン アイテムの属性を取得しようとしています。このコードは、利用可能なすべての属性を検索し、それらのタグとコンテンツを出力する必要があります。
ドキュメントによると、 「cdat」のようなタグが表示されるはずですが、代わりにインデックスのように見えます (つまり、最初のタグは 0、次は 1 です)。これは、探している属性がどれか分からないため、かなり役に立ちません。
SecItemClass itemClass;
SecKeychainItemCopyAttributesAndData(itemRef, NULL, &itemClass, NULL, NULL, NULL);
SecKeychainRef keychainRef;
SecKeychainItemCopyKeychain(itemRef, &keychainRef);
SecKeychainAttributeInfo *attrInfo;
SecKeychainAttributeInfoForItemID(keychainRef, itemClass, &attrInfo);
SecKeychainAttributeList *attributes;
SecKeychainItemCopyAttributesAndData(itemRef, attrInfo, NULL, &attributes, 0, NULL);
for (int i = 0; i < attributes->count; i ++)
{
SecKeychainAttribute attr = attributes->attr[i];
NSLog(@"%08x %@", attr.tag, [NSData dataWithBytes:attr.data length:attr.length]);
}
SecKeychainFreeAttributeInfo(attrInfo);
SecKeychainItemFreeAttributesAndData(attributes, NULL);
CFRelease(itemRef);
CFRelease(keychainRef);