示例#1
0
        private void installRootCertToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                X509Certificate2 rootCert = new X509Certificate2(CertManager.GetRootCert().Export(X509ContentType.Cert));

                if (CertificateUtils.FindCertByThumbprint(StoreName.Root, StoreLocation.CurrentUser, rootCert.Thumbprint) != null)
                {
                    MessageBox.Show(this, Properties.Resources.MainForm_RootCertAlreadyInstalled, Properties.Resources.MessageBox_ErrorString,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    CertManager.AddCertToStore(StoreName.Root, StoreLocation.CurrentUser, rootCert);
                }
            }
            catch (CryptographicException)
            {
            }
        }