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 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.