[release/6.0-staging] Fix exporting certificate keys on macOS 14.4. #99781
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #99768 to release/6.0-staging
/cc @vcsjones @bartonjs
Customer Impact
Reported by customers in #99735. Apple made a changes in macOS 14.4 that prevented private keys from
X509Certificate2
from exporting. This affected customers that used APIs to get the exported key from a certificate in the macOS keychain.Regression
Apple changed the error code returned by one of their APIs. The change caused our error handling logic to not handle a recoverable error and instead treat it as an uncaught error.
Testing
Unit tests were added to prevent the fix from regressing.
Risk
Low. The change only affects macOS specific code and adds another error code to an already existing error handling path. The fix simply ensures we take the same error handling path with the new error code, in addition to the old one.