title: Can't import Code-signing Public or Private keys using Keychain access (Mac OS X Mavericks)
body: <p>In an attempt to build an iOS project (in XCode), I need to import my colleague's public and private keys for the code signing identity, but I am unable to do so because I get an error in Keychain Access that says "An error has occurred. Unable to import an item. / The contents of this item cannot be retrieved"</p>
  
  <p>FULL DETAILS:</p>
  
  <p>I have got two keys from my colleague's computer, exported them from his Keychain as two files:</p>
  
  <p>Roomer Inc.p12 (the private key)</p>
  
  <p>Roomer Inc.pem (the public key)</p>
  
  <p>When he exported these, he left the password blank (Although we also tried with a password of "test" and got the same results). </p>
  
  <p>When I double-click Roomer Inc.p12 (for the private key), it opens in Keychain Access and promts me to choose the keychain ("login" is selected by default)</p>
  
  <p>I click "Add" and then I am prompted for the password to the keychain (which I leave blank)</p>
  
  <p>Next I always see this message in Keychain access:</p>
  
  <p><img src="https://content.screencast.com/users/JasonFB/folders/Jing/media/e79e8557-ac7c-49ab-812d-e14b03b0f46c/00000545.png" alt="screenshot of error"></p>
  
  <p>However, despite this message appearing, when I click OK, I see a new private key entry for "Roomer Inc". Note that this entry is a private key in the "login" key chain as I would expect, but has no expiration date (should it?)</p>
  
  <p>Next, for the Roomer Inc.pem file (the public key) I am asked to choose the keychain ("login") and I click Add</p>
  
  <p>Then, I also get the "An error has occurred. Unable to import an item. / The contents of this item cannot be retrieved" message for the public key as well. In this case however (unlike the Private key), I do not see any entry corresponding for what I just added.</p>
  
  <p>So, it appears that the private key entry may or may not be OK (I have no way to verify), and the public key entry for Roomer cannot be installed in the keychain without this error message. Please note that I also tried using the security import command to import the public key :</p>
  
  <p>$ security import Roomer\ Inc.pem -f pkcs12 ~/Library/Keychains/login.keychain</p>
  
  <p>1 key imported.</p>
  
  <p>When I do this, although the command returns "1 key imported" I do not see a public key for "Roomer Inc" in my Keychain Access window (I closed out Keychain Access and re-opened it).</p>
  
  <p>Either way, we have identified that this is our blocker. (The symptom of course is that the XCode project won't build for the AdHoc provisioning profile to be used with TestFlight). I have left off the additional steps regarding the XCode build and TestFlight setup, because we believe the core problem has to do with importing the keys as explained above. </p>