Skip to content
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

X509Store app certificate becomes unusable after a while #2765

Open
1 of 5 tasks
mregen opened this issue Sep 17, 2024 · 1 comment
Open
1 of 5 tasks

X509Store app certificate becomes unusable after a while #2765

mregen opened this issue Sep 17, 2024 · 1 comment

Comments

@mregen
Copy link
Contributor

mregen commented Sep 17, 2024

Type of issue

  • Bug
  • Enhancement
  • Compliance
  • Question
  • Help wanted

Current Behavior

System.ArgumentException
  HResult=0x80070057
  Message=The CNG key handle being opened was detected to be ephemeral, but the EphemeralKey open option was not specified. (Parameter 'keyHandleOpenOptions')
  Source=System.Security.Cryptography.Cng
  StackTrace:
   at System.Security.Cryptography.CngKey.Open(SafeNCryptKeyHandle keyHandle, CngKeyHandleOpenOptions keyHandleOpenOptions)
   at Internal.Cryptography.Pal.CertificatePal.GetPrivateKey[T](Func`2 createCsp, Func`2 createCng)
   at Internal.Cryptography.Pal.CertificatePal.GetRSAPrivateKey()
   at Internal.Cryptography.Pal.CertificateExtensionsCommon.GetPrivateKey[T](X509Certificate2 certificate, Predicate`1 matchesConstraints)
   at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.GetRSAPrivateKey(X509Certificate2 certificate)
   at Opc.Ua.Security.Certificates.X509PfxUtils.VerifyRSAKeyPair(X509Certificate2 certWithPublicKey, X509Certificate2 certWithPrivateKey, Boolean throwOnError) in D:\Source\Repos\UA-.NETStandard10\Libraries\Opc.Ua.Security.Certificates\X509Certificate\X509PfxUtils.cs:line 78

  This exception was originally thrown at this call stack:
    [External Code]
    Opc.Ua.Security.Certificates.X509PfxUtils.VerifyRSAKeyPair(System.Security.Cryptography.X509Certificates.X509Certificate2, System.Security.Cryptography.X509Certificates.X509Certificate2, bool) in X509PfxUtils.cs

Expected Behavior

self signed certificate remains usable in X509Store

Steps To Reproduce

  • Use X509Store and CurrentUser/My as app certificate store
  • Start ref server and connect with UA Expert or other clients
  • Restart a few times.
  • Eventually the above exception is thrown.

Environment

- OS: Windows 11 23H2
- Environment: VS 2022
- Runtime: .NET 8.0 / .NET Framework 4.8
- Nuget Version: 1.5.374.118
- Component: 
- Server: Ref server
- Client:

Anything else?

No response

@romanett romanett removed their assignment Oct 3, 2024
@mregen
Copy link
Contributor Author

mregen commented Oct 17, 2024

so far not reproducible on all machines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants