I am trying to export the X509Certificate2 certificate public key using the following code:
X509Store certificateStore = new X509Store(StoreName.My, StoreLocation.CurrentUser); certificateStore.Open(OpenFlags.ReadOnly); var exportCertificates = certificateStore.Certificates.Find(X509FindType.FindByThumbprint, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", false); certificateStore.Close();
When I execute the last line, the following exception is thrown:
System.Security.Cryptography.CryptographicException Cannot find the requested object
Does anyone know how to solve this?
NOTE. The sample code above is "functional", but this is psuedo code. In fact, I export the certificate to one application, and then transfer it to another for the purpose of digital signatures (from here only sending the public key)
source share