I accidentally deleted my "var/keychains" folder in my jailbroken iPhone 4 thinking that it would solve a problem to a tweak that wasn't work, and now my iPhone is not recognizing the passwords I enter into the phone. It keep asking me to enter my voicemail password, email passwords..etc. I can't even access youtube. I also can't sync my iPhone 4 to my iTunes because there aren't any valid files in the Keychains folder. I have recreated the folder, but I did not back up any of the files in it. I was suspecting that the iPhone would recreate those files once I deleted them, but I was wrong. Can anyone help me out here? I can't restore my iPhone because I haven't backed up any of my important data. I can still use the iPhone, but these inquiries are irritating me hugely.


You are probably in pretty bad shape here, the system keychains are generally created as part of the iPhone's activation process (they include things like the APNS certificate, which is negotiated with Apple during activation). Even if you do manage to create a new keychain, all the certs on it will be different, which means that anything that has exchanged keys with your iPhone (like push notifications, encrypted backups, etc) won't work.

You might be able to create an empty keychain by using the security commandline tool. I am not sure if that is actually installed on the iPhone by default. You might also be able to create an empty toolchain on a Mac and copy it over, but I am not sure if the iPhone keychain is format compatible with the Mac OS X one.

I think it is important to remind people, if you don't know exactly what you are doing then mucking with system files can be very dangerous, and you should always make sure you copy the original files so you can revert it.

  • I actually did decrypt a backup that was from a few weeks ago with a program called "iPhone Backup Extractor", and I found the following files in it. oscpcache.sqlite3, keychain-backup.plist, TrustStore.sqlite3, and some other miscellaneous folders. I remember that oscpcache.splite3 and Trustore.sqlite3 and keychain-2.db was in the Keychains folder. Im not sure how to recreate it again. – Kevin Aug 28 '10 at 13:49
  • 1
    If you have copies of keychain-2.db, oscpcache.splite3, and Trustore.sqlite3 then just copy them back into "/private/var/Keychains/" and you should be good. – Louis Gerbarg Aug 28 '10 at 14:18
  • The only file I dont have is keychain-2.db – Kevin Aug 28 '10 at 17:52
  • That is the one with your actual data, the others are incidental. The only thing I can think of is if you can somehow force a iTines to reactivate the phone. – Louis Gerbarg Aug 28 '10 at 20:56
  • 1
    +1 for the "if you don't know what your doing, backup the original" – Rudiger May 3 '11 at 5:29

I don't know if this will work for a jailbroken phone.*

If your iTunes back up of your iPhone is not encrypted then it will not back up your keychain. You should be able to disable encryption, then do a back up. A restore from this point should create a new keychain for you.

*Don't blame me if you lose all your data.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .