Keychain error -34018 (errSecMissingEntitlement)

This thread has been locked by a moderator.

This is a continuation of from the old forums: https://devforums.apple.com/thread/246122


Calling SecItemCopyMatching will sometimes return an OSStatus of -34018 (errSecMissingEntitlement). This seems to happen when the system is running low on memory. This has not been fixed in iOS9. I've of course filed radars about this and I would encourage others to do the same while iOS 9 is under development.

Up vote post of briandw
99k views

Replies

Just to add my voice to the noise, Xcode 7.1 and iOS 9.1 this is STILL a bug.


In my scenario it seems to happen when users update the App. Reading from the Keychain fails immediately and then the user is forced to login again. BUT, since reading and writing to Keychain fails its a stalemate. I did see a solution that simply involved crashing the app whenever this occured but I'm not sure I'm comfortable with that.


Since all we are storing in the Keychain is the users access tokens, I think i'm going to move that into NSUserDefaults as this just isnt worth the time. We do use Safari Credential Sharing and havent experience any issues with that so for those who are struggling maybe thats a better option?

Has there been ANY update on this since July? I knowthe Facebook SDK team is having real trouble with this and causing a lot of Apps to be rejected from the store due to login bugs.


Can we please get an update on where Apple engineers are at with fixing this bug and what we as developers can do to work around it in prior versions of iOS where this issue will remain prevalent?

Adding my voice to say that it is happening in the latest Xcode (7.1) while debugging an iPhone 6 with 9.1. Any and all keychain access results in -34018, but then if I run the exact same build outside of the debugger, without rebooting my phone, all accesses work.


I am desperate for a workaround.

Workaround...get the app built and copied to the phone, and then start the app from the device (not the debugger). Then, attach the debugger to the running process. This seems to get around whatever timing issue is breaking this, and the various keychain operations appear to work correctly while debugging.

Confirming totvos workaround. Works as a temporary solution. Would be nice to have this resolved properly.

Thanks for sharing the workaround totvos!

Seeing reports that this is happening in production Apps. Is anyone else able to confirm? https://github.com/soffes/sskeychain/issues/52


Feedback/workarounds from Apple would be appreciated...

An update on this would be appreciated. Very frustrating issue.

An update on this would be appreciated. Very frustrating issue.

Alas, I don’t have any helpful info to share. This is a bug that, AFAIK, keychain engineering is still hunting (r. 19844807). Moreover, while there’s lots of anecdotal suggestions for ways to avoid the problem, AFAIK the only guaranteed workaround is to restart the process, which is not very helpful when you’re talking about an iOS app.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you Quinn.


How can I get updates on the bug resolution? As we try to workaround it in over 60 applications, you can imagine the coordination required to update them all, and the risk of introducing a new issue.


Unfortunately, having zero information on an issue with this kind of impact does not allow me to do any kind of damage control with my clients.


Thanks

Thank you Quinn for your updates.


But what can we do to help here? Are there still issues replicating the bug? I think it's been pretty well documented.


This has been going on for too long. Our apps are unreliable bacause of this and our users are leaving us.


Apple is really hanging us out to dry with this.

How can I get updates on the bug resolution?

Probably the best option here is to file your own bug about it. That’ll get closed as a duplicate, at which point you’ll be able to see the status of the original.

It’s not ideal (for example, you’ll have to poll for changes) but it’s the best you can do in the current setup.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Just to add to the discussion, I'm also suffering with this problem.


Months ago, I was seeing the -34018 error when accessing the keychain quite often. However, I turned off ARC for the file that was doing keychain access, started doing the memory management manually, and I haven't seen the problem for a long time - over 6 months. However, I started seeing it again recently (since iOS 9.1 and XCode 7.1.1). No idea why (Xcode and iOS updates might be a coicidence), but yes it always seems to happen when bringing the app back into the foreground.


The keychain was indeed being accessed in applicationWillEnterForeground: so I've moved that to applicationDidBecomeActive: and will see if that elleviates the problem.

You are both wrong.

The issue happens in App Store versions too.

The cause is a memory stress that probably cause the securityd process to fail with its connection to the keychain.

When this one happens the only thing to do is kill the app, kill other apps to release some memory and only then open the app.

The bug was reported back in 2013 and Apple didn't do anything until today with the claim this is hard to reproduce. Thousand developers reported this bug but Apple can't reproduce. Sounds funny.

Anyway, Don't trust the details you reported as this one is just around the corner for everyone.

Can confirm the -34018 error is still present in iOS 9.2. 😟