I use KeychainItemWrapper to store an identifier of my users in keychain of iOS. I noticed that when we uninstall the app, the identifier persist in the keychain yet; but I'm wonder Does iOS will clean the items automatically when the keychain goes so big? or some other applications can remove or access the items?
It will be deleted if the device is wiped or restored, whatever that resets your device.
Access to the keychain is tied to the provisioning profile used to sign the app. Consequently no other apps would be able to access that app's keychain info. This answers your question about some other App being able to access your App's keychain items or not.
For reference: Same Question on Apple Developer Forum
Related
In AppStore when an app transferred to different account and new account publish new version, does Apple remove app's keychain data due to encryption?
Thank you.
I'm really confused and hence asking this - does every iOS app has it's own keychain on device(iPhone) or there is only one keychain on device (iPhone) which is used by the different apps ?
Thanks
As mentioned in Apple docs. For the iPhone, there is only one keychain and apps can store their keychain items in it.
In iOS, apps have access to a single keychain (which logically
encompasses the iCloud keychain). This keychain is automatically
unlocked when the user unlocks the device and then locked when the
device is locked. An app can access only its own keychain items, or
those shared with a group to which the app belongs. It can't manage
the keychain container itself.
Reference: https://developer.apple.com/documentation/security/keychain_services/keychains
Our iOS app is transfer from Account A to B, Earlier we had used the certificates which was created in Account A and upload a build on iTunes Connect using certificates of Account A.
Now when we uploading app on iTunesconenct for Beta Testing that time we have used the certificates which was created in Account B(Due to Transfer App Account).
So, Now application identifier of the live app is different from the application identifier of the Beta TestFlight Testing App on App Store. And we have got the warning potential loss of keychain access.
Right Now, We are using SSKeychain Wrapper for Store UUID to track user.
[SSKeychain setPassword:UUID forService:#"com.example.appname” account:#“appname” error:&error]
If App ID Prefix changed then SSKeychain loss it’s access?
Because We track UUID in database for further use using SSKeychain. My doubt is if APPID Prefix changed then it is also effect the SSKeychain and it is generate new UUID for all devices?
So, How we can solve this issue ? Please let us know about solutions of this issue.
The keychain access is tied to the App(s) ID Prefix(s). They must have the same prefix. We had a case where different Apps in the same Developer Account and different Prefix(s) and they would not share the same keychain access. Had to have Apple fix so all were the same.
In your case, if you move the app to account B, the App ID will have a different prefix and would not be able to access the "old" keychain.
As far as I know there is NO workaround for this if the App Prefix has changed.
Yes, all devices would get a new keychain store for data and would not be able to access the "old" keychain data.
I noticed that my identifierForVendor always changes. Someone told me that it doesn't change when you download from iTunes. I'm not so sure about it, though. So, I want to store the first identifierForVendor generated. I found this class, JNKeychain from one of the posts i checked. It can store password and other data. I tried using that to store my identifierForVendor. Even after deleting my app and reinstalling using XCode, I was able to get the value I stored. Sounds good because this way, my identifierForVendor can persist regardless of whether it was downloaded from iTunes or not. However, I"m not very familiar with Keychain. I didn't even know we can store secure data using it. I read their documentation and it says there it's usually used to share data between applications and your apps should have same provisioning profile etc... I don't plan on sharing. I just want it to save my identifier so this is not a concern for me. My only concern is how long will my data last in the keychain storage? Will it be deleted after some time? or when I turn off my device? When i update ios version? Can it persist forever? Will keychain have a different behavior if I use developer/distribution profile?
The keychain entry will last as long as the device is not wiped or hard-reset or until the app deletes it. Apps can be deleted and replaced, but the keychain entry will remain. If an app from developer profile is overlaid with enterprise profile or app store the keychain entry should be fine.
If I put some information into the keychain, my app is the only one who is able to have access to that data, correct?
The keychain data are shared across a developer's applications.
From the apple documentation:
Keychain data for an app is stored outside of the app’s sandbox. When
the user backs up app data using iTunes, the keychain data is also
backed up. Before iOS 4.0, keychain data could only be restored to the
device from which the backup was made. In iOS 4.0 and later, a
keychain item that is password protected can be restored to a
different device only if its accessibility is not set to
kSecAttrAccessibleAlwaysThisDeviceOnly or any other value that
restricts it to the current device. Upgrading an app does not affect
that app’s keychain data.
Here is an example of sharing keychain information between applications.
The data an app puts into the Keychain is restricted to a single developer's apps. It can be shared by multiple apps by the same developer if desired or restricted to that app.
See WWDC13 2013 video "Protecting Secrets with the Keychain". You can access it either on you computer or on an iOS device with the Apple WWDC app.