I have our own CNG provider. Using c# with .net framework 4.6.1 with window 7. I am using clrsecurity.
string fp = "223298a5c7c9f78a42d83a5ffbxxxxxxxx";
//string fp = "331ffa497d90d19446171f85xxxxxxxx"; //MS
// Load the certificate with the specified serial number
X509Store store = new X509Store(StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = store.Certificates.Find(X509FindType.FindBySerialNumber, fp, false);
// check if at least one certificate has been found
if (certificates.Count != 1)
{
throw new Exception("The certificate with the serial number " + fp + " could not be found.");
}
X509Certificate2 cert = certificates[0];
CngKey cngKey = null;
if (cert.HasCngKey())
{
//rsa = cert.GetRSAPrivateKey();
cngKey = cert.GetCngPrivateKey();
}
The problem is I am not able to set the provider name into CngKey object. So how to use the clrsecurity dll for non Microsoft KSP.