chooseClientCert() { /* X509InitiatorCertificateClientElement config = new X509InitiatorCertificateClientElement(); * config.StoreLocation = System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine; * config.StoreName = CertificateStoreLocation.GetStoreName();*/ X509Certificate2 cert = CertificateChooser.ShowDialog(StoreLocation.LocalMachine, StoreName.My, true); if (cert != null) { textBox1.Text = cert.SerialNumber; } //config.FindValue = cert.SerialNumber; //return config; }
public static X509Certificate2 ShowDialog(StoreLocation location, StoreName name, bool showonlyCertsWithPrivateKeys) { CertificateChooser f = new CertificateChooser { _location = location, _name = name }; X509Store s = new X509Store(name, location); s.Open(OpenFlags.ReadOnly); X509Certificate2Enumerator it = s.Certificates.GetEnumerator(); while (it.MoveNext()) { X509Certificate2 cert = it.Current; if (!showonlyCertsWithPrivateKeys || (showonlyCertsWithPrivateKeys && cert.HasPrivateKey)) f.listBox1.Items.Add(cert.Subject + " | " + cert.SerialNumber); } f.ShowDialog(); return f.cert; }
public static X509Certificate2 ShowDialog(StoreLocation location, StoreName name, bool showonlyCertsWithPrivateKeys) { CertificateChooser f = new CertificateChooser { _location = location, _name = name }; X509Store s = new X509Store(name, location); s.Open(OpenFlags.ReadOnly); X509Certificate2Enumerator it = s.Certificates.GetEnumerator(); while (it.MoveNext()) { X509Certificate2 cert = it.Current; if (!showonlyCertsWithPrivateKeys || (showonlyCertsWithPrivateKeys && cert.HasPrivateKey)) { f.listBox1.Items.Add(cert.Subject + " | " + cert.SerialNumber); } } f.ShowDialog(); return(f.cert); }