Using kSecValueRef as the only parameter works fine. Do you know why the function does not work when other parameters, for example, kSecClass, are provided? The key binding service reference documents the first SecItemAdd() parameter as follows:
A dictionary containing a key-value element class of a pair [...] and an optional key-value pair of the attribute [...] specifying the value attribute item.
I suggested that kSecClass is a required parameter that should always be present when using SecItemAdd() oder SecItemCopyMatching() . The tasks of the certificate, key, and trusted services in iOS explain the process of adding SecIdentityRef to the keychain as follows (Listing 2-3):
CFDataRef persistentRefForIdentity(SecIdentityRef identity) { OSStatus status; CFTypeRef identity_handle = NULL; const void *keys[] = { kSecReturnPersistentRef, kSecValueRef }; const void *values[] = { kCFBooleanTrue, identity }; CFDictionaryRef dict = CFDictionaryCreate(NULL, keys, values, 2, NULL, NULL); status = SecItemAdd(dict, &persistent_ref); if (dict) CFRelease(dict); return (CFDataRef)persistent_ref; }
Is this example incorrect?
mbinna
source share