Added Methods for Changing The Keychain Password. #54

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
1 participant

eahrold commented Dec 16, 2013

Added two new methods to SSKeychain

+ (BOOL)changeDefaultKeychainPassword:(NSString*)currentPassword to:(NSString*)newPassword;
+ (BOOL)changePasswordForKeychain:(NSString*)keychain from:(NSString*)currentPassword to:(NSString*)newPassword;

Added four properties SSKeychainQuery

@property (nonatomic, copy) NSString *keychain;
@property (nonatomic, copy) NSString *keychainPassword;
@property (nonatomic, copy) NSString *keychainPasswordNew;
@property int keychainPreferenceDomain;

I also wired up the SSKeyChainQuery method to allow for setting a specific keychain
So now if you want to modify keychains other than the default one you could something like this

SSKeychainQuery *query = [[SSKeychainQuery alloc]init];
query.account  = @"myacct";
query.password = @"mypass";
query.service =  @"myservice";
query.keychain = @"altKeychain";
        /* or */
query.keychain = @"/User/username/Library/Keychains/altKeychain.keychain";
[query save:&error];

This would be easy enough to add to the SSHKeychain Class, but I debated wether it would start to make it cluttered, so I leave it up to you as the architect. Let me know and I'll do another pull request with that code.

I also built out the SSKeychainQuery's Private query method with an error pointer in order to catch any Sec failures that happened when determining the keychain. The query now returns NULL if a keychain was specified but cannot be found, so other methods now do a check immediately after the query and return NO on failure

Also included is an Target.app with simple example code, as well as XCTests for os X.

@eahrold eahrold closed this May 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment