matthewpalmer / Locksmith

A powerful, protocol-oriented library for working with the keychain in Swift.
MIT License
2.92k stars 268 forks source link

deleteDataForUserAccount not failing, but not deleting data #119

Open mhuusko5 opened 8 years ago

mhuusko5 commented 8 years ago

I'm updateData(forUserAccount:inService:) successfully , loadDataForUserAccount successfully, deleteDataForUserAccount seemingly successfully (doesnt catch/fail), but then loadDataForUserAccount still works/loads the data that should have been deleted.

matthewpalmer commented 8 years ago

Hmm strange. Which version of Locksmith and iOS? Also if you can reliably reproduce a sample project would be super helpful. Thanks!

On 13 Apr 2016, at 12:27 AM, Mathew Huusko V notifications@github.com wrote:

I'm updateData(forUserAccount:inService:) successfully , loadDataForUserAccount successfully, deleteDataForUserAccount seemingly successfully (doesnt catch/fail), but then loadDataForUserAccount still works/loads the data that should have been deleted.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub

JanBorowskiES commented 8 years ago

I have same problem. Locksmith (2.0.8), iOS 9.2 One weird thing. It seems like deletion works great until I terminate app. After termination and restart "deleted" data is available again through Locksmith.

piotr-dudek commented 8 years ago

Hi @matthewpalmer

Seems that I just run into the same problem.

In my case I am unable to read or write to the Keychain after I presentViewController UIImagePickerController. Strange... Locksmith.loadDataForUserAccount() returns nil, deleteDataForUserAccount() and saveData() exits without throwing any error. After restarting the app I can read from the Keychain, also data that supposed to be deleted still exists.

After some debugging and googling I think it may be related to a mysterious bug in the Keychain which manifests itself as the OSStatus -34018. https://forums.developer.apple.com/thread/4743 In the Locksmith this code is not handled and falls into if statement: https://github.com/matthewpalmer/Locksmith/blob/6b32c7ec68324f33f2b8fb0765213c74a6f86dd5/Source/Locksmith.swift#L87, probably why writing and reading exits without any error.

I am able to reproduce it but not in every iteration and only if the app is connected with Xcode (debug mode, iOS 9.2.1).

@JanBorowskiES @mhuusko5 Maybe setting breakpoints in the method linked above will help you verify if it is the same problem (not handled error code and/or bug in the iOS Keychain).

alaxicsmith commented 8 years ago

I'm having the same issue. Any one come up with a solution?

bdrelling commented 7 years ago

Same issue on this now and it's December 15th. How did this get solved?

gaborcsontos commented 7 years ago

Same issue! Still available the data, after using deleteData method with Locksmith...

christwsy-zz commented 6 years ago

Same here. Would like to know if that's a human error or not. Running v4.0.0 with iOS 11.2.2 iPhone 6.

Update: I've been testing this with synchronously and asynchronously dispatch queue and found that if you put this deleteDataForUserAccount(userAccount:) inside an async DispatchQueue, it might cause the problem.

My solution in the mean time is just to run the delete method synchronously.