Error accessing certificate private key after 2025-10 cumulative update

Miguel Ángel Martínez Durán 10 Reputation points
2025-10-17T10:14:17.9+00:00

Hi.

We have a Windows application developed on C# .NET Framework 4.5.2.

Since the last cumulative update it's throwing an error every time we try to access the PrivateKey property of a X509Certificate2.

X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
// pick certificate from store.Certificates;
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider)certificate.PrivateKey; // This one crashes

Stacktrace is:

System.Security.Cryptography.CryptographicException: invalid provider type specified. in System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) in System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle) in System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair() in System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32 dwKeySize, CspParameters parameters, Boolean useDefaultKeySize) in System.Security.Cryptography.X509Certificates.X509Certificate2.get_PrivateKey()

Certificates use sha256RSA and do work without problem outside our app, for example in Adobe Acrobat signing a PDF.

We traced the error to updates KB5066791 if windows 10 and KB5066835 if windows 11. Uninstalling them makes everything work again, but doesn't sound like a good idea to force thousands of our clients to roll back those updates

Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
{count} votes

3 answers

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 2,700 Reputation points Microsoft External Staff
    2025-10-17T12:51:05.5066667+00:00

    Thank you for reaching out.

    I recommend not to roll back the updates.

    Uninstalling KB5066791 (Windows 10) or KB5066835 (Windows 11) might make the issue disappear temporarily, but it’s not recommended because:

    • These updates include critical security fixes.
    • Rolling them back exposes systems to vulnerabilities and compliance risks.
    • Microsoft’s direction is to move away from legacy cryptographic APIs, so this problem will return in future updates.

    Workarounds you can try instead

    Upgrade the .NET Framework
    Move from 4.5.2 to at least 4.6 or later. Modern cryptographic APIs introduced in 4.6 handle CNG keys correctly.

    Re-import certificates using a CSP provider
    If code changes are not immediately possible, you can re-import the certificate with a legacy CSP key provider. This is a temporary workaround and not ideal for security.

    Use X509KeyStorageFlags when loading PFX files
    If your app loads certificates from PFX, try adding flags like MachineKeySet or Exportable. This can resolve access issues in some service contexts.

    Check private key permissions
    Ensure the application’s process identity has the correct ACL permissions on the private key in the certificate store. The update enforces stricter checks.

    Update middleware for hardware-backed keys
    If using HSMs or smart cards, confirm that the vendor’s middleware is updated and compatible with the new security changes.

    Plan for application update
    Even if temporary fixes help, the long-term solution is to update the application to use modern APIs that support CNG keys. This aligns with Microsoft’s security roadmap.

    Let me know if you need any further help with this. We'll be happy to assist.

    If you find this helpful, please mark this as answered.


  2. Romain LAGRANGE 0 Reputation points
    2025-10-18T17:06:03.6733333+00:00

    Hi, just to reiterate here about this issue that we also have.

    We are using 462 and have the same issue. Same with 4.8. But it still work in .net9.

    As we are using this method to check for computer certificate before authentication and app update check, we have to manually update our app on 500 computers that are now unable to start.

    Thanks Microsoft

    0 comments No comments

  3. Petar Masev 0 Reputation points
    2025-10-21T09:03:34.96+00:00

    Hey everybody 🙋‍♂️

    We have the same issue. There was an update few moments ago, but it was about the USB devices issue in windows recovery environment. The 'Invalid provider type specified' issue is still active.

    I recommend the delay of the default cryptographic provider change till there is a fix. Or give us an option to choose the one by ourselves. Thank you!

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.