Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

removeObjectForKey: gives "Could not store(Delete) string. Error was:-25300" #26

Open
evgeniyd opened this issue Sep 27, 2016 · 4 comments

Comments

@evgeniyd
Copy link

Calling

[[PDKeychainBindings sharedKeychainBindings] removeObjectForKey:@"myKey"];

returns

Could not store(Delete) string. Error was:-25300

While investigating it, I've found that this is a custom NSLog string, logged when the following operation fails:

OSStatus result=SecItemDelete((__bridge CFDictionaryRef)spec);
if (result!=0) {
    NSLog(@"Could not store(Delete) string. Error was:%i",(int)result);
}

The error code from OSStatus enum declared in <Security/SecBase.h>has this description:

errSecItemNotFound = -25300,  /* The specified item could not be found in the keychain. */

...which points out, that it's just the value being not found for respective key upon deleting.

Question

I wonder, what option here would be more preferable?

  1. I have to check for key existence, before attempting to delete it?
  2. The PDKeychainBindingsController has to have a fix to check the key, before deleting
  3. The PDKeychainBindingsController has to have a fix to make error codes processing and logging more accurate
  4. Ignore everything here (which was the way, it worked before this bug report was submitted)
@evgeniyd
Copy link
Author

FYI. So far, my workaround:

if ([[PDKeychainBindings sharedKeychainBindings] objectForKey:@"myKey"]) {
    [[PDKeychainBindings sharedKeychainBindings] removeObjectForKey:@"myKey"];
}

@dhurley14
Copy link

@evgeniyd have you tried adding Keychain Sharing in your capabilities (entitlements) file? See here

@danielkramer
Copy link

Interesting, I've tried the testing for the existence of the key as you've suggested but I still get the same crash and error.

@evgeniyd
Copy link
Author

@danielkramer hm, I do not have my app crashed upon the error. It is just the message, I don't prefer to be printed to the console.
Do you see the same log message?

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

3 participants