nicklockwood / fxkeychain Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED]
License: Other
[DEPRECATED]
License: Other
Hi! I am using a custom class which conforms to NSCoding. I am getting an error + assertion inside setObject:forKey:
NSAssert(!object || (object && data), @"FXKeychain failed to encode object for key '%@', error: %@", key, error);
And [NSPropertyListSerialization propertyListWithData:options:format:error] produces this error:
Property list invalid for format: 200 (property lists cannot contain objects of type 'CFType')
My class conforms to NSCoding so I put a breakpoint on encodeWithCoder: and noticed that encodeWithCoder: is never being called. Any ideas what I am doing wrong?
Thanks!
Hi whenever i set or get data with key i'l get this message in console:
CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 1. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug.
i use last version of keychain(1.4) on iOS (7.1b4)
When adding a keychain item through SecItemAdd, one can specify the kSecAttrAccessible to specify when a keychain item should be readable.
I believe that if the kSecAttrAccessible is not specified, the default protection class is kSecAttrAccessibleWhenUnlocked, which means that the keychain item can only be accessed while the device is unlocked.
However, there are cases where caller would like to specify the keychain item to be readable after first unlock (kSecAttrAccessibleAfterFirstUnlock and kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly). This is especially true with iOS 7 where new multi-tasking APIs are added to support background fetch and download/upload. During these background operations, device could be in the locked state and keychain items might be needed for authentication among other things.
@nicklockwood great library! For those of us building cross-platform frameworks it would be great to have tvOS and watchOS support in the podspec file.
Are there any issues with setting the accessibility level in the app delegate applicationDidFinishLoading??
[FXKeychain defaultKeychain].accessibility = FXKeychainAccessibleAlways;
Any saving within your basic "FXKeychainExample" app results in "FXKeychain failed to store data for key 'password', error: -34018" - Works just fine in XCode 5/iOS 7.0/7.1
This error occurs when running in simulator. It works fine on an actual device. Any clue what the issue may be?
As a follow up to #8, is there any reason why the accessibility
property is readonly
?
Shouldn't I be able to set it on the default keychain as long as I set it before I assign any values in the keychain?
I suppose that move info.plist out of FXKeychain folder. Because I suffered from that info.plist "no such file", and I checked my project over and over again and my info.plist is there, but when I start to complie, Xcode 7.0 always warn me about that the file “Info.plist” couldn’t be opened because there is no such file.
. It about to drive me crazy, and I have to work with my project. So I changed my Xcode version to 6.4, A Ha, Finally it says more like that "Keychains/FXKeychain/FXKeychain/Info.plist:0: " , I finally got that I forget to move the FXKeychain folders to my project . If only I used the package manager to make integration.
This line https://github.com/nicklockwood/FXKeychain/blob/master/FXKeychain/FXKeychain.m#L141
is returning nil for when object is a standard NSDictionary
on OS X 10.9, and the NSAssert that comes afterwards kicks in.
I don't believe there's anything special in the NSDictionary
, 21 key/value pairs, gets saved without issues on an iOS keychain with another library.
The code seems correct, so I'm wondering what can be wrong, still investigating, if you have any idea I'll be happy to try.
There is an issue using shared keychain items only in Yosemite using iOS 8 simulators. It appears that the kSecAttrAccessGroup is now needed in this specific configuration. Keychain calls that would previously fail when including the kSecAttrAccessGroup key with an error of -25243 are now successful. Further, the shared keychain does not appear to be globally available to the simulator requiring the kSecAttrAccessGroup key to be used. I simply commented out the simulator check in dataForKey: and setObject:forKey:
//#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
if ([_accessGroup length]) query[(__bridge NSString *)kSecAttrAccessGroup] = _accessGroup;
//#endif
I haven't figured out any other way around this issue yet.
Update: I'm using OS X Yosemite v10.10.1 (14B25) and Xcode 6.1 (6A1052d)
i don't know if this makes sense or not: how about adding a method like:
- (NSArray *)allKeys
that returns all the keys in a keychain?
i'm using FXKeychain to keep track of N servers, and i'd like to be able to present a list to the user of servers that they have keys for.
Any thoughts on this? Or can this already be done with FXKeychain and I just don't know it?
The string "pass;'word", with a semicolon and an ampersand, is returned as an NSDictionary when being read from the keychain using objectForKey.
When getting a value from the keychain fails, it would be nice if it was possible to get the last status result. Was it errSecItemNotFound
or errSecInteractionNotAllowed
, for instance?
(on iOS) my class is loading from a file and when I try and access a property i'm getting an error about NSDictionary being "not key value coding-compliant for the key XXX". While i can see that at the time of the crash the instance of the object is in fact an NSDictionary, my perception is that it should actually inflate as the class that it was saved as.
my class is an instance of BaseModel, and was previously using BMFileFormatKeyedArchive (which works), but this particular class that i'm saving I'd like to make more secure.
Today I've got a problem that even after reinstalling the app I get FXKeychain already saved previous options. On the first load,
FXKeychain *keychain = [FXKeychain defaultKeychain];
i get
[keychain objectForKey:kUserGUID]
not nil,
I get a previous value somehow. I'm not sure where the problem is. If someone still using this pod, any help would be appreciated.
But I see the last commit is about 2 years ago, probably should just stop using it, maybe some parts are just deprecated for current ios version.
I tried using FXKeyChain to save different items to the keychain but I was getting errors. To show this I patched the basic example with the code at gradha@f590521 which shows saving three specific values after the one specified by the user in the example. These values are not saved, as displayed by the following log:
2013-03-21 19:23:13.632 FXKeychainExample[12469:c07] FXKeychain failed to store data for key '1', error: -25299
2013-03-21 19:23:13.645 FXKeychainExample[12469:c07] FXKeychain failed to store data for key '2', error: -25299
2013-03-21 19:23:13.649 FXKeychainExample[12469:c07] FXKeychain failed to store data for key '3', error: -25299
Also, if I press the save button on the unmodified example, change the name of the key to something else and press save again, I get a similar error:
2013-03-21 19:24:23.173 FXKeychainExample[12469:c07] FXKeychain failed to store data for key 'passw', error: -25299
This seems to be contrary to the README where it says Each FXKeychain can contain as many key/value pairs as you want, so you may only need a single FXKeychain per application. Can you tell what is wrong with these modifications? Maybe keychain access changed in iOS 6 devices and you have to create one instance for key/value?
It would be nice to have a "description" method implemented to list all the keychain entries like in a UICKeyChainStore.
I couldn't find anything about this in the readme nor the code
This error comes sometimes while reading data from shared keychain by multiple apps. Can somebody explain what's causing this?
Don't think this is an FXKeyChain issue but for info - updating a key fails with a -25300 error (errSecItemNotFound).
Sample code (as per radar which is a cut down version of FXKeyChain attached below)
/// ---------------------------------------------------------
//
// ViewController.m
// KeychainBugSample
//
// Created by Andy Qua on 12/02/2014.
// Copyright (c) 2014 Andy Qua. All rights reserved.
//
#import "ViewController.h"
/*******
* Sample demonstrating a bug with updating a value stored in the KeyChain.
* When running on Simulator this fails with a -25300 error (errSecItemNotFound)
* But works fine when running on device
*
* Note this is simplified keychain code and assumes that you will be saving and retrieving an NSString value
*******/
@interface ViewController ()
{
NSString *service;
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
service = @"test";
NSString *key = @"MyKey";
NSString *text;
// Key shouldn't exist
text = [self stringForKey:key];
NSLog( @"Before add - value stored - [%@]", text );
// Set value
[self addString:@"Test" forKey:key];
// Make sure that value has been set correctly
text = [self stringForKey:key];
NSLog( @"After initial add - value stored - [%@]", text );
// Now Update the value - This will log error -25300 (keyNotFound)
[self updateString:@"This has changed" forKey:key];
// Make sure that value has been set correctly
text = [self stringForKey:key];
NSLog( @"After update value - [%@]", text );
// Clear outs data from keychain for next run
[self deleteDataForKey:key];
text = [self stringForKey:key];
NSLog( @"After delete value - [%@]", text );
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSString *)stringForKey:(id)key
{
//generate query
NSMutableDictionary *query = [NSMutableDictionary dictionary];
if ([service length]) query[(__bridge NSString *)kSecAttrService] = service;
query[(__bridge NSString *)kSecClass] = (__bridge id)kSecClassGenericPassword;
query[(__bridge NSString *)kSecMatchLimit] = (__bridge id)kSecMatchLimitOne;
query[(__bridge NSString *)kSecReturnData] = (__bridge id)kCFBooleanTrue;
query[(__bridge NSString *)kSecAttrAccount] = [key description];
//recover data
CFDataRef data = NULL;
OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&data);
if (status != errSecSuccess && status != errSecItemNotFound)
{
NSLog(@"Failed to retrieve data for key '%@', error: %ld", key, (long)status);
}
NSData *dataObj = CFBridgingRelease(data);
NSString *text = [[NSString alloc] initWithData:dataObj encoding:NSUTF8StringEncoding];
return text;
}
- (BOOL) addString:(NSString *)string forKey:(NSString *)key
{
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
NSMutableDictionary *query = [NSMutableDictionary dictionary];
if ([service length]) query[(__bridge NSString *)kSecAttrService] = service;
query[(__bridge NSString *)kSecClass] = (__bridge id)kSecClassGenericPassword;
query[(__bridge NSString *)kSecAttrAccount] = [key description];
query[(__bridge NSString *)kSecValueData] = data;
OSStatus status = SecItemAdd ((__bridge CFDictionaryRef)query, NULL);
if (status != errSecSuccess)
{
NSLog(@"Failed to add data for key '%@', error: %ld", key, (long)status);
return NO;
}
return YES;
}
- (BOOL) updateString:(NSString *)string forKey:(NSString *)key
{
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
NSMutableDictionary *query = [NSMutableDictionary dictionary];
if ([service length]) query[(__bridge NSString *)kSecAttrService] = service;
query[(__bridge NSString *)kSecClass] = (__bridge id)kSecClassGenericPassword;
query[(__bridge NSString *)kSecAttrAccount] = [key description];
NSMutableDictionary *update = [@{(__bridge NSString *)kSecValueData: data} mutableCopy];
OSStatus status = SecItemUpdate((__bridge CFDictionaryRef)query, (__bridge CFDictionaryRef)update);
if (status != errSecSuccess)
{
NSLog(@"Failed to update data for key '%@', error: %ld", key, (long)status);
return NO;
}
return YES;
}
- (BOOL)deleteDataForKey:(id)key
{
//generate query
NSMutableDictionary *query = [NSMutableDictionary dictionary];
if ([service length]) query[(__bridge NSString *)kSecAttrService] = service;
query[(__bridge NSString *)kSecClass] = (__bridge id)kSecClassGenericPassword;
query[(__bridge NSString *)kSecAttrAccount] = [key description];
//delete existing data
OSStatus status = SecItemDelete((__bridge CFDictionaryRef)query);
if (status != errSecSuccess)
{
NSLog(@"Failed to delete data for key '%@', error: %ld", key, (long)status);
return NO;
}
return YES;
}
@end
/// ---------------------------------------------------------
It would be convenient to be able to do:
[keychain reset];
instead of having to manually delete each key for a given keychain service.
(This probably wouldn't make sense to allow on the default keychain).
I see that Valet differentiates between Sharing Secrets Among Multiple Applications
and Sharing Secrets Across Devices with iCloud
. Can we have an option that prevents items from being synced to iCloud ? Maybe the lack of kSecAttrSynchronizable
means no iCloud support?
Hi guys
I'm trying to use FXKeychain (used another one before, but this one seemed very solid ;p ).
When running on my device (iOS8 b4), I keep getting this error message :
FXKeychain failed to store data for key 'kPasswordKeychainKey', error: -25243
but it work just fine on the simulator. I tried to add Data protection capabilities, it generated the entitlement.plist file, but I can't get to to work on my device.
Any idea?
thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.