Late answer but answer nonetheless:
I struggled with updating the items in the keychain, my context was a little different though.
What happened:
I could successfully add a keychain element (using SecItemAdd ), but the SecItemUpdate call on the same element failed with the notorious errSecParam -50 .
Worse yet; if the keychain element already exists (so I immediately called SecItemUpdate ), the update passed without any problems.
I have no idea why this happened ...
How I fixed it:
Pretty simple actually, I just deleted the "params" until I was satisfied with a big bad -50 . This happened when I removed kSecClass from a dictionary retrieved from kSecItemCopyMatching .
Here is my code:
As a reference, I used the following dictionaries
self.searchQueryDict contains:
(__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword (__bridge id)kSecAttrService : service (__bridge id)kSecAttrGeneric : [identifier dataUsingEncoding:NSUTF8StringEncoding] (__bridge id)kSecMatchLimit : (__bridge id)kSecMatchLimitOne (__bridge id)kSecReturnAttributes : (__bridge id)kCFBooleanTrue (__bridge id)kSecReturnData : (__bridge id)kCFBooleanTrue
self.updateQueryDict contains:
(__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword, (__bridge id)kSecAttrService : service, (__bridge id)kSecAttrGeneric : [identifier dataUsingEncoding:NSUTF8StringEncoding]
dictToSave must contain the values ββ(in the correct format) that need to be changed
Removing kSecClass fixed the problem for me.
source share