Example #1
0
 private void selectCertButton_Click(object sender, EventArgs e)
 {
     using (OpenFromCertStoreForm form = new OpenFromCertStoreForm())
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             SelectedCert = form.SelectedCert;
         }
     }
 }
Example #2
0
 private void openCertFileButton_Click(object sender, EventArgs e)
 {
     if (openCertificateDialog.ShowDialog(this) == DialogResult.OK)
     {
         string fileName = openCertificateDialog.FileName;
         if (null == (fileName = CertFileItem.TryCreate(fileName, out CertFileItem result)))
         {
             SelectedCert = result;
         }
         else
         {
             MessageBox.Show(this, fileName, "Load Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Example #3
0
        private void certFromClipboardButton_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText())
            {
                switch (ParsedCertItem.TryCreate(Clipboard.GetText(), out ParsedCertItem cert))
                {
                case ParsedCertItem.ParseResult.Success:
                    SelectedCert = cert;
                    return;

                case ParsedCertItem.ParseResult.Base64DecodeError:
                    MessageBox.Show(this, "Clipboard does not contain valid base-64 encoded data.", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;

                case ParsedCertItem.ParseResult.CertificateLoadErr:
                    MessageBox.Show(this, "Cannot create certificate from decoded data.", "Invalid Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            MessageBox.Show(this, "Clipboard does not contain base-64 encoded text.", "No Certificate", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }