ICloud syncs keychain

In my application, I want to be able to synchronize the configuration that the user creates. I wanted to use iCloud to synchronize this configuration so that it was always the same on all devices. But I use a keychain to store the password.

Is there a way to sync keychain data?

+7
ios objective-c cocoa-touch icloud
Jul 15 '12 at 6:16
source share
4 answers

No, keychain synchronization is not part of iCloud. This was part of mac point synchronization, but it is no longer available.

Feedback will likely be received on whether this is a good idea or not (automatically moving passwords from one device to another), especially in a situation where several people use an iCloud account (probably, but not guaranteed these days).

If you think that you save the password on the device’s key fobs (and therefore requiring the user to enter it at least once on the device), you will need to provide your own encryption and security and store data in iCloud directly, for example, in the keystore.

+3
Jul 15 '12 at 11:44
source share

iCloud Keychain is a new feature in iOS 7.0.3 and OS X Mavericks 10.9. Specify the kSecAttrSynchronizable attribute when adding a keychain element using the SecItem API.

+16
Oct 27 '13 at 18:41
source share

These are the utilities that I created for the keychain. kSecAttrSynchronizable is what iCloud Sync does. Hope they help.

  • Key binding request.
  • Delete item
  • Delete item
  • Save item
  • Download item

     + (NSMutableDictionary *)getKeychainQuery:(NSString *)service { return [NSMutableDictionary dictionaryWithObjectsAndKeys: (__bridge id)kSecClassGenericPassword, (__bridge id)kSecClass, service, (__bridge id)kSecAttrService, service, (__bridge id)kSecAttrAccount, service, (__bridge id)kSecAttrSynchronizable, (__bridge id)kSecAttrAccessibleAfterFirstUnlock, (__bridge id)kSecAttrAccessible, nil]; } + (void)save:(NSString *)service data:(id)data { NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; SecItemDelete((__bridge CFDictionaryRef)keychainQuery); [keychainQuery setObject:[NSKeyedArchiver archivedDataWithRootObject:data] forKey:(__bridge id)kSecValueData]; SecItemAdd((__bridge CFDictionaryRef)keychainQuery, NULL); } + (void)remove:(NSString *)service { NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; SecItemDelete((__bridge CFDictionaryRef)keychainQuery); } +(NSString *)keychainItem:(NSString *)service{ id data = [self load:service]; if([data isKindOfClass:[NSString class]]){ return data; } return @""; } + (id)load:(NSString *)service { id ret = nil; NSMutableDictionary *keychainQuery = [self getKeychainQuery:service]; [keychainQuery setObject:(id)kCFBooleanTrue forKey:(__bridge id)kSecReturnData]; [keychainQuery setObject:(__bridge id)kSecMatchLimitOne forKey:(__bridge id)kSecMatchLimit]; CFDataRef keyData = NULL; if (SecItemCopyMatching((__bridge CFDictionaryRef)keychainQuery, (CFTypeRef *)&keyData) == noErr) { @try { ret = [NSKeyedUnarchiver unarchiveObjectWithData:(__bridge NSData *)keyData]; } @catch (NSException *e) { NSLog(@"Unarchive of %@ failed: %@", service, e); } @finally {} } if (keyData) CFRelease(keyData); return ret; } 
+2
Sep 16 '15 at 10:43
source share

Looking at the same, have not tried it yet, but it looks useful: https://github.com/iosengineer/BMCredentials

0
Nov 10 '15 at 2:29
source share



All Articles