-
Notifications
You must be signed in to change notification settings - Fork 29
Add support for the Data Protection Keychain #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit allows to store certificates from the Data Protection Keychain, This functionality only works on code-signed applications. This commit also includes a fix that allows to retrieve a key from the data protection key chain depending on the uri parameters.
kms/mackms/mackms.go
Outdated
// Apple recommends to set KSecUseDataProtectionKeychain parameters always | ||
// to true for all keychains operations. This option requires to use a | ||
// code-signed application. | ||
if u.useDataProtectionKeychain { | ||
dict[security.KSecUseDataProtectionKeychain] = cf.True | ||
// The data in the keychain item cannot be accessed after a restart |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to detect the required entitlements are available in the program? If so, when the intention is to use the data protection keychain, and the application isn't codesigned / missing entitlements, can it return an error indicating that case? This may not be necessary if errors from the OS are clear enough, but I've seen enough OSError codes that weren't overly clear 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently it should be possible to know this using SecCodeCheckValidity . We can add this in a different PR.
The current behavior is:
- When loading a certificate you will get a not found error. Something like:
mackms LoadCertificate failed: not found
- When storing a certificate you will get an error showing that an entitlement is missing:
mackms StoreCertificateChain failed: OSStatus -34018: A required entitlement isn't present.
Co-authored-by: Herman Slatman <hslatman@users.noreply.github.com>
Description
This PR adds support for storing certificates in the Data Protection Keychain. This functionality is only available for code-signed applications.
Additionally, this commit includes a fix that enables retrieving a key from the Data Protection Keychain or not based on URI parameters.
This last fix slightly changes the behavior: previously, keys stored in the Secure Enclave could be retrieved without specifying
se=true
, but it was not possible to retrieve the proper key if a key in the Secure Enclave shares the same label as a key in the login keychain.