How do I show and select one of the digital certificates on my computer

2

In my work environment I have some certificates and I need to select one of them, I would like to know via VN.Net or C # code how do I display a list and choose the digital certificate that I need without having to assign this list of certificates in a combobox .

Code

    Dim ListaCertificados As New List(Of X509Certificate2)()
Private Sub ReloadCerts()

    Dim Store As X509Store = New X509Store(StoreName.My, StoreLocation.CurrentUser)
    Store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)

    Dim _certs As X509Certificate2Collection = Store.Certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, True).Find(X509FindType.FindByKeyUsage, X509KeyUsageFlags.DigitalSignature, True)

    For Each Certificado In _certs

        If Certificado.HasPrivateKey Then

            ListaCertificados.Add(Certificado)
            Certificado.GetNameInfo(X509NameType.SimpleName, False)

        End If
    Next
End Sub
    
asked by anonymous 05.02.2015 / 13:18

1 answer

4

Based on in this answer in the OS you can do what you want. The form of search is that it has to be different (taking advantage of the code placed in the comment would look like this:

Dim certificateCollection As X509CertificateCollection = X509Certificate2UI.SelectFromCollection(Store.Certificates, "Caption", "Message", X509SelectionFlag.SingleSelection)
    
05.02.2015 / 16:45