in Vault/Explorer/MainForm.cs [414:445]
private async void uxMenuItemAddKVCertificate_Click(object sender, EventArgs e)
{
CertificateDialog certDlg = null;
// Add certificate
using (var dtf = new DeleteTempFileInfo())
{
// Add certificate from file
if ((sender == uxAddKVCertFromFile) || (sender == uxAddKVCertFromFile2))
{
dtf.FileInfoObject = GetFileInfo(sender, e);
if (dtf.FileInfoObject == null) return;
certDlg = new CertificateDialog(this, dtf.FileInfoObject);
}
// Add certificate from store
if ((sender == uxAddKVCertFromUserStore) || (sender == uxAddKVCertFromMachineStore) || (sender == uxAddKVCertFromUserStore2) || (sender == uxAddKVCertFromMachineStore2))
{
var cert = Utils.SelectCertFromStore(StoreName.My, (sender == uxAddKVCertFromUserStore) || (sender == uxAddKVCertFromUserStore2) ? StoreLocation.CurrentUser : StoreLocation.LocalMachine, CurrentVaultAlias.Alias, Handle);
if (cert == null) return;
certDlg = new CertificateDialog(this, cert);
}
// DialogResult.Cancel is when user clicked cancel during password prompt from the ctor(), if OK was clicked, check for duplication by Name and Md5
if ((certDlg != null) && (certDlg.DialogResult != DialogResult.Cancel) && (certDlg.ShowDialog() == DialogResult.OK) && ListViewItemBase.VerifyDuplication(this, null, certDlg.PropertyObject))
{
using (var op = NewUxOperationWithProgress(uxButtonAdd, uxMenuItemAdd))
{
ListViewItemCertificate lvic = null;
await op.Invoke("add certificate to", async () => lvic = await ListViewItemCertificate.NewAsync(this, certDlg.PropertyObject, op.CancellationToken));
AddOrReplaceItemInListView(lvic);
}
}
}
}