Overview
We are investigating repeated "login" Keychain prompts affecting our macOS application on macOS 26.6.x.
The issue appears after upgrading an existing installation. A clean uninstall/reinstall of the same version resolves it.
Changing the affected Keychain item's Access Control from "Confirm before allowing access" to explicitly allowing our application/process also stops the prompts.
On one affected machine, Apple Support observed a securityd crash followed by:
SecKeyCreateSignature failed
CSSMERR_DL_INVALID_DB_HANDLE
Our code uses some legacy SecKeychain* APIs, so we are currently investigating whether this is related.
Questions
- Were there any changes in macOS 26.6.x around
securityd, Keychain ACL handling, or legacySecKeychain*APIs that could explain this? - Could an existing Keychain ACL become stale after an application upgrade, even when both versions are signed with the same Developer ID?
Thanks for all that additional info. Most interesting.
securityd is a bit like the kernel. You shouldn’t be able to crash it just by calling its API. Rather, if you make a mistake like this, securityd should start returning errors or, in extreme circumstances, kill you.
Given that, this failure is automatically bugworthy, and I’d appreciate you filing a bug report about it, including a sysdiagnose log taken shortly after reproducing the problem. Please post your bug number, just for the record.
Looking at the crash report I have some theories as to why it actually crashed, but I don’t want to go too far down that rabbit hole. Rather, I’d like to stay focused on what you’re doing.
1- Is our root cause plausible from your side?
It’s certainly plausible. Regardless, the current behaviour of your keychain code is clearly wrong, and thus you should fix that.
2- Is fully moving to SecItem the right long-term direction … ?
Yes, but…
or is there extra guidance for apps that still need to scope lookups to a specific keychain?
There are likely to be exceptions in your case.
I suspect you’ve already read TN3137 On Mac keychain APIs and implementations but, if not, I encourage you to take a look at it now. The key takeaways are:
- Keychain has two implementations (file-based and data protection).
- The file-based keychain implementation is deprecated.
Moving to the SecItem API is a necessary to get off the file-based keychain, but it’s not sufficient. To start, you have to explicitly opt in, but there are further complications. If parts of your product run outside of a user context then the data protection keychain isn’t an option. You have to stick with the file-based keychain, and specifically the System keychain.
So:
- It definitely makes sense to move to the SecItem API.
- And avoid the deprecated file-based keychain APIs as much as possible (more on this below).
- Moving to the data protection may not be possible.
- Even if it is, it’s a non-trivial task and not something I’d recommend for a bug fix release.
When working with the file-based keychain my general advice is:
- Stick with the SecItem API as much as possible.
- If you need control over which file-based keychain you act on, use
kSecMatchItemList(for queries) andkSecUseKeychain(for adds). - Try to avoid using custom keychains.
- Rather, target the standard login keychain (assuming you’re in a user context) and system keychain (in any context).
- Which you can get to via
SecKeychainCopyDefault. Or, in the rare cases where it doesn’t do the right thing,SecKeychainCopyDomainDefault.
Where we still need user-vs-system scoping, we build the search list via SecKeychainCopyDomainSearchList
Yeah, that’ll work too (-:
It turns out Apple's own airportd triggers the exact same [problem]
Well, that’s not good. Make sure to mention that in your bug report.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"