New cert loader should load into CNG by default#107005
Conversation
When no provider attribute is present on a key, Windows loads the key into the CAPI Base provider unless PKCS12_PREFER_CNG_KSP is set. So, set that flag. On .NET Framework (or .NET Standard running on .NET Framework) we don't have the power to set that flag (without completely redefining how the PFX load loads), so inject a synthetic attribute to force keys into the CNG KSP when PreserveStorageProvider isn't set. Technically these two approaches differ when the incoming PFX has no name and PreserveStorageProvider is set (CoreFX: CNG, NetFX: CAPI Base), but that's unlikely, and consistent with .NET Framework imports.
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
|
BTW I've heard that the |
.../System/Security/Cryptography/X509Certificates/X509CertificateLoaderPkcs12CollectionTests.cs
Outdated
Show resolved
Hide resolved
vcsjones
left a comment
There was a problem hiding this comment.
Looks fine to me. Some non-blocking feedback for clarity in a test, but functionally looks good.
Yes it does.
It does. If that is the behavior people want, they can specify Hedging against likely follow up question..
I think the idea was entertained when X509CertificateLoader` was being spiked out, but it can't work for two reasons.
So, if you know your scenarios work with ephemeral keys, you can opt-in to it. |
|
/ba-g The tests appear to have run successfully on all legs (infrastructure issue preventing them from uploading results?) |
|
/backport to release/9.0 |
|
Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10586588721 |
When no provider attribute is present on a key, Windows loads the key into the CAPI Base provider unless PKCS12_PREFER_CNG_KSP is set. So, set that flag.
On .NET Framework (or .NET Standard running on .NET Framework) we don't have the power to set that flag (without completely redefining how the PFX load loads), so inject a synthetic attribute to force keys into the CNG KSP when PreserveStorageProvider isn't set.
Technically these two approaches differ when the incoming PFX has no name and PreserveStorageProvider is set (CoreFX: CNG, NetFX: CAPI Base), but that's unlikely, and consistent with .NET Framework imports.
Fixes the problem identified in #104487.