-
Notifications
You must be signed in to change notification settings - Fork 5
/
BatchCertificateContainerImportForm.cs
60 lines (51 loc) · 1.86 KB
/
BatchCertificateContainerImportForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
namespace X509CertificateTool
{
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Windows.Forms;
internal partial class BatchCertificateContainerImportForm : Form
{
public BatchCertificateContainerImportForm()
{
InitializeComponent();
}
public BatchCertificateContainerImportForm(BatchCertificateContainer container) : this()
{
this.FillListView(container);
}
private void FillListView(BatchCertificateContainer container)
{
this.listView1.BeginUpdate();
container.Certs.ToList().ForEach(certData =>
{
ListViewItem lvi = new ListViewItem(certData.StoreLocation.ToString());
lvi.SubItems.Add(certData.StoreNameAsString);
lvi.SubItems.Add(certData.CertSubject);
lvi.Tag = certData;
listView1.Items.Add(lvi);
});
this.listView1.EndUpdate();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
private void buttonOK_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
private void listView1_DoubleClick(object sender, EventArgs e)
{
listView1.SelectedItems.Cast<ListViewItem>().Select(
lvi => lvi.Tag).Cast<CertData>().ToList().ForEach(certData =>
{
X509Certificate2 cert = certData.GetX509Certificate2ClientWillCallReset();
X509Certificate2UI.DisplayCertificate(cert);
cert.Reset();
});
}
}
}