title: Duplicate item when saving certificate identities in the iOS Keychain
body: <p>I'm trying to figure out what exactly means the status code <code>errSecDuplicateItem</code> for the <code>SecItemAdd</code> method when trying to add a certificate identity to the iOS keychain.</p>
  
  <p>Reading the iOS documentation, it only says that this status code means the item is duplicated in the keychain, but what is the criteria to determine if an identity is a duplicate? Issuer name? Expiration date? Both? </p>
  
  <p>If you read to the Mac OSX documentation, the discussion section for <a href="http://developer.apple.com/library/mac/documentation/security/Reference/certifkeytrustservices/Reference/reference.html#//apple_ref/c/func/SecCertificateAddToKeychain" rel="nofollow">a similar</a> method says the following:</p>
  
  <blockquote>
    <p>If the certificate has already been added to the specified keychain,
    the function returns errSecDuplicateItem and does not add another copy
    to the keychain. The function looks at the certificate data, not at
    the certificate object, to determine whether the certificate is a
    duplicate. It considers two certificates to be duplicates if they have
    the same primary key attributes.</p>
  </blockquote>
  
  <p>I know there is a difference, I'm trying to save the certificate identity in the keychain, and this discussion is for the <code>SecCertificateAddToKeychain</code> method which saves the certificate; but I believe there is a connection.</p>
  
  <p>What's the meaning of <code>"primary keys attributes"</code>?</p>
  
  <p>I tried adding the same identity twice and of course I get the <code>errSecDuplicateItem</code>, but I'm afraid that users may get an error if they want to update the certificate in someway I'm not considering.</p>
  
  <p>Any thoughts?</p>
  
  <p>Thanks in advance</p>