I have this function that looks for the certificate by the serial:
public static X509Certificate2 EscolherCertificado()
{
var store = new X509Store("MY", StoreLocation.CurrentUser);
X509Certificate2 x509 = null;
var Key = new RSACryptoServiceProvider();
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = store.Certificates;
X509Certificate2Collection fcollection = collection.Find(X509FindType.FindBySerialNumber, "serialcertificadoaqui", false);
if (fcollection.Count == 1)
{
return fcollection[0];
}
else { return null; }
}
But at first I will not know the serial, how can I get the certificate's serial number through a function? Without the user typing, is it possible?