[release/10.0] Fix EC-DSA / EC-DH PEM key loading with PKCS#8 key load attributes #123036
+511
−40
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 #122997 to release/10.0
/cc @vcsjones
Customer Impact
Customer reported in #122925. Customers that use
X509Certificate2.CreateFromPemmay receive an error when importing an EC-DSA on Windows, preventing them from importing the key.This is because the key import mechanism only observed the key usages on the certificate. It did not observe the usages on the key itself.
Regression
This regressed in .NET 10 from #115249. That pull request fixed a similar issue with EC-DH, but caused the EC-DSA scenario to regress.
Testing
New tests were added to cover all new scenarios. Existing tests were in place to ensure known scenarios continued to work.
Risk
Low. Between the previous certificate-based test variance and the new key-based test variance, both sides of the cert+key pairing are covered.