Extract ECDSA non-exportable private key from x509 certificate

120 Views Asked by At

I have a x509 certificate stored in windows certificate store and it contains a ECDSA private key marked as non-exportable.

How can I retrive the private key for signing in C# with .Net framework 4.7.2?

X509Store store = new X509Store("StoreName", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
X509Certificate2 Cert = null;
if(store.Certificates.Count > 0)
{
Cert = store.Certificates[0];
}
                    
var CertPK = Cert.GetECDsaPrivateKey(); // return null

The Private key is associated with the certificate

enter image description here

and the public key type is as the image

enter image description here

0

There are 0 best solutions below