-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[7.0-rc1] Fix PopulateCertificatesFromStore on macOS to only return store certs #43358
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
[7.0-rc1] Fix PopulateCertificatesFromStore on macOS to only return store certs #43358
Conversation
@MackinnonBuck this fixes the issue we were looking at. |
@HaoK PTAL |
// Note that the actual certs we populate need to be the ones from the store location, and | ||
// not the version from disk, since we may do other operations with these certs later (such | ||
// as exporting) which would fail with crypto errors otherwise. | ||
var onDiskAndKeychain = certsFromStore.Intersect(certsFromDisk, ThumbprintComparer.Instance); |
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.
We should probably consider at least starting a list of some of these things for maybe a single CTI scenario for to do some ad hoc verification every once in a while, given that we don't have any test coverage for these kinds of things, (for our future selves)
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.
This was actually caught by the WebTools CTI team (see linked issue) as part of their RC 1 pass.
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.
Awesome, so we do have coverage, that makes me feel better that they are exercising things then
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.
Its good that CTI catches this :)
Filed #43374 for the failing H3 test. |
Some certificate export scenarios (exporting to a PEM file for instance) will lead us to try to export an RSA private key. Without this change, the first one of these exports works, and then subsequent ones fail with a vague crypto exception from
SecKeyCopyExternalRepresentation
.The fix is simple; we have code in the certificate manager that takes the union of certificates in the new on-disk location and the store (keychain).
The code was previously doing:
which meant that the actual certs returned were the ones loaded from disk (and also happened to be in the keychain), whereas what we want to return is the certs from the keychain that also have on-disk versions. The reason why it works the first time is that the on-disk versions don't exist yet.
This change flips the Intersect call and adds a comment about all of this. While I was here I also noticed a typo on a nearby store location check so I fixed that too.
Fixes #43335