Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (m_opt.Validate())
            {
                using (var dlg = new SaveFileDialog())
                {
                    dlg.Filter = "Key File|*.pfx";
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        using (var cert = CertificateMaker.GenerateSelfSignedCertificate(m_opt.KeyType, m_opt.CommonName, m_opt.StartDate, m_opt.EndDate))
                        {
                            File.WriteAllBytes(dlg.FileName, cert.Export(X509ContentType.Pkcs12, txtPassword.Text));
                        }
                        MessageBox.Show("Done!");
                    }
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("Invalid");
            }
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (m_opt.Validate())
            {
                using (var dlg = new SaveFileDialog())
                {
                    dlg.Filter = "Key File|*.pfx";
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        CertificateMaker.GenerateSelfSignedCertificate(string.Format("CN={0}", m_opt.CommonName), m_opt.StartDate, m_opt.EndDate, m_opt.SignatureBit, m_opt.KeyStrength, txtPassword.Text, dlg.FileName);
                        MessageBox.Show("Done!");
                    }
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            else
            {
                MessageBox.Show("Invalid");
            }
        }