Search code examples
ioskeychain

Modification date of a keychain item in iOS 4.x


In my app, I am storing a set of credentials in the keychain for offline access. When someone logs in while the device is offline, I retrieve the keychain item, check the kSecAttrModificationDate, and compare that to a value the app already has to determine whether the credentials have expired or not.

That is all well and good in iOS 5.x. But in iOS 4.x kSecAttrModificationDate does not exist in the keychain item data dictionary.I checked the doc and it says this is available since iOS 2.0. And if I skip the modification date check, the item is retrieved correctly from the keychain.

Is anyone aware of any 4.x vs 5.x differences in this area? I searched the Apple dev forums and google and couldn't find anything useful.


Solution

  • Found the answer. kSecAttrModificationDate exists by default for iOS 5+, but not for iOS 4.x. It has to be added manually.