Skip to content
This repository has been archived by the owner on Aug 24, 2019. It is now read-only.

setPassword:forService doesn't update old keys #11

Closed
kilianc opened this issue Sep 17, 2012 · 13 comments
Closed

setPassword:forService doesn't update old keys #11

kilianc opened this issue Sep 17, 2012 · 13 comments

Comments

@kilianc
Copy link

kilianc commented Sep 17, 2012

[SSKeychain setPassword:[passwordTextField stringValue] forService:@"" account:@"test"];

It does work the first time, then it doesn't update the same key.

@soffes
Copy link
Owner

soffes commented Sep 18, 2012

It definitely does. I've used it in dozens of applications and this is tested in the unit tests. My guess is there is a keychain issue unrelated to SSKeychain. Are you on Mac or iOS?

Don't get me wrong, there could be a bug, but I do this really often. If you can post a simple test app that reproduces it, that would also help.

On Sep 17, 2012, at 3:20 PM, Kilian Ciuffolo notifications@github.com wrote:

[SSKeychain setPassword:[passwordTextField stringValue] forService:selectedServiceName account:@"test"];
doesn't work


Reply to this email directly or view it on GitHub.

@kilianc
Copy link
Author

kilianc commented Sep 18, 2012

I will post here a sample app. I will be happy to discover that the problem is in my code :)

P.S. yes I am on mac.

@jun1st
Copy link

jun1st commented Sep 18, 2012

I think I got the same problem, the new value isn't saved to keychain.

jun1st.feng@gmail.com
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Tuesday, September 18, 2012 at 3:49 PM, Kilian Ciuffolo wrote:

I will post here a sample app. I will be happy to discover that the problem is in my code :)
P.S. yes I am on mac.


Reply to this email directly or view it on GitHub (https://github.com/samsoffes/sskeychain/issues/11#issuecomment-8644322).

@soffes
Copy link
Owner

soffes commented Sep 18, 2012

I've seen lots of issues on Mac. It's likely due to a code signing issue or of you're using Developer ID, there are a lot of known issues. See http://samsoff.es/posts/developer-id-and-10-8

Sam
Sent from my iPhone

On Sep 18, 2012, at 4:09 AM, Derek notifications@github.com wrote:

I think I got the same problem, the new value isn't saved to keychain.

jun1st.feng@gmail.com
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Tuesday, September 18, 2012 at 3:49 PM, Kilian Ciuffolo wrote:

I will post here a sample app. I will be happy to discover that the problem is in my code :)
P.S. yes I am on mac.


Reply to this email directly or view it on GitHub (https://github.com/samsoffes/sskeychain/issues/11#issuecomment-8644322).


Reply to this email directly or view it on GitHub.

@johndemic
Copy link

Having the same issue on 10.8.2, not using code signing or developer ID. Replacing the password doesn't work nor does deleting and adding again. Here's a Gist of my code: https://gist.github.com/3925465 In this case the logging statement on line 17 will print the original password instead of nil. Setting the password again on line 21 has no effect.

@kilianc
Copy link
Author

kilianc commented Oct 29, 2012

Any update/workaround on this, that's really annoying :(

@soffes still need my project? I can send it to you.

@soffes
Copy link
Owner

soffes commented Oct 29, 2012

Sure. Like I said before, I am 90% sure this is a bug in Keychain and not in SSKeychain. If you can provide a reproducible example project I can do some investigation.

@kakysha
Copy link

kakysha commented Dec 11, 2012

Code:

if ([SSKeychain setPassword:[credentials valueForKey:@"password"] forService:@"myservice" account:[credentials valueForKey:@"login"] error:&e]) 
        NSLog(@"Password for %@ is stored in keychain", [credentials valueForKey:@"login"]);
     else NSLog(@"Can't store the password in keychain, error:%@", [e localizedDescription]);

Log:

2012-12-11 03:18:37.141 MyApp[8658:303] Can't store the password in keychain, error:The operation couldn’t be >completed. (com.samsoffes.sskeychain error -25299.)

Error 25299 from Security framework:

errSecDuplicateItem          = -25299,  /* The specified item already exists in the keychain. */

But when i delete username from keychain manually, it saves the password. So the problem is in updating already presented keys.

P.S. In fact, [deletePassword] return YES, but the password is kept in keychain :(

@kilianc
Copy link
Author

kilianc commented Dec 11, 2012

P.S. In fact, [deletePassword] return YES, but the password leaves in keychain :(

You mean the password is kept in keychain even if you delete it?

@kakysha
Copy link

kakysha commented Dec 11, 2012

You mean the password is kept in keychain even if you delete it?

Exactly!

@soffes
Copy link
Owner

soffes commented Dec 11, 2012

I've seen this before. It was a code signing issue that caused all writes to fail. SSKeychain should have better support for errors (but if I remember correctly, the Security APIs didn't return any when this is the issue). I think it was an issue with Developer ID. I had to build on 10.7 to fix.

I'm going to close this since it's a Keychain issue and not an SSKeychain issue.

@soffes soffes closed this as completed Dec 11, 2012
@paulmelnikow
Copy link
Contributor

I encountered this issue building on Mac OS 10.7 for Mac OS 10.6.

In the past I've worked around this by modifying the existing item with SecKeychainItemModifyAttributesAndData like in this code. I'm going to try to modify SSKeychain to do the same.

@petetak
Copy link

petetak commented Mar 4, 2015

Great work fixing the delete password for OSX @paulmelnikow - thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants