-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
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
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.
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 |
Holla
Envoyé de mon iPhone
Le 27 août 2024 à 04:07, Theodore Tsirpanis ***@***.***> a écrit :
BTW I've heard that the NCrypt APIs perform an RPC call to a system process and I was wondering if the same happens with a key obtained from PFXImportCertStore and if yes, whether passing PKCS12_NO_PERSIST_KEY and/or using the earlier Crypto API to get the certificate's private key would change anything.
—
Reply to this email directly, view it on GitHub<#107005 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AUW2LQ7MBPS2F57JCBTM62TZTPGLHAVCNFSM6AAAAABNFAZJUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJRGM3TKMRVGY>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
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.