Note that there are some explanatory texts on larger screens.

plurals
  1. POKeychainItemWrapper migrating data throws error
    primarykey
    data
    text
    <p>I'm using the ARCified <a href="https://gist.github.com/dhoerl/1170641" rel="nofollow"><code>KeychainItemWrapper</code></a> and having trouble migrating the data in one keychain item to another item. Basically I'm trying to copy the contents from an app specific item to a shared item. For brevity I've only put in the user name since it fails there.</p> <pre><code>KeychainItemWrapper *legacyKeychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"mainLogin" accessGroup:@"C35BXHSRSA.com.foo.bar"]; NSString *legacyUser = [legacyKeychainItem objectForKey:(__bridge id)kSecAttrAccount]; self.migratedKeychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"security" accessGroup:@"C35BXHSRSA.com.foo.security"]; // dies here [self.migratedKeychainItem setObject:legacyUser forKey:(__bridge id)kSecAttrAccount]; </code></pre> <p>It dies in the <code>KeychainItemWrapper</code> method <code>writeToKeychain</code> throwing <code>NSAssert( result == noErr, @"Couldn't update the Keychain Item." );</code></p> <p>Looking up the error in the <a href="https://developer.apple.com/library/mac/#documentation/security/Reference/keychainservices/Reference/reference.html" rel="nofollow">Keychain Services Reference</a> tells me </p> <blockquote> <p>errSecDuplicateItem –25299 The item already exists.</p> </blockquote> <p>I can confirm this issue by hard coding/altering the string and the code works perfectly, but I'm trying to migrate data... so identical is important. The question is, why is this throwing an error when it's 2 different keychain items and how the heck do I get it to work as desired?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload