private void ImportCertificatesFromDomainController(string connection)
 {
     try
     {
         var xcert      = LdapSecureConnectionCertificateFetcher.FetchServerCertificate(connection);
         var cert       = new X509Certificate2(xcert);
         var thumbprint = cert.GetFormattedThumbPrint();
         foreach (ListViewItem item in lstCertificateChain.Items)
         {
             if (((CertificateDto)item.Tag).Chain == thumbprint)
             {
                 MMCDlgHelper.ShowWarning("Certificate with the same fingerprint already exists");
                 return;
             }
         }
         var values = new string[] { cert.Subject, cert.Issuer, cert.GetEffectiveDateString(), cert.GetExpirationDateString(), thumbprint };
         var lst    = new ListViewItem(values)
         {
             Tag = new CertificateDto {
                 Encoded = cert.ExportToPem(), Chain = thumbprint
             }
         };
         lstCertificateChain.Items.Add(lst);
         MMCDlgHelper.ShowWarning(string.Format("Certificate with subject {0} imported successfully", cert.Subject));
     }
     catch
     {
         // do nothing
     }
 }
示例#2
0
        void ImportCertificates(string connection)
        {
            try
            {
                var xcert           = LdapSecureConnectionCertificateFetcher.FetchServerCertificate(connection);
                var cert            = new X509Certificate2(xcert);
                var thumbprint      = cert.GetFormattedThumbPrint();
                var certfificateDto = new CertificateDto {
                    Encoded = cert.ExportToPem(), Chain = thumbprint
                };

                var exists = _certificates.Exists(x => x.Chain == thumbprint);
                if (exists)
                {
                    UIErrorHelper.ShowAlert("Certificate with the same fingerprint already exists", "Error");
                    return;
                }
                _certificates.Add(certfificateDto);
                ReloadCertificates();
                UIErrorHelper.ShowAlert(string.Format("Certificate with subject {0} imported successfully", cert.Subject), "Information");
            }
            catch (Exception exception)
            {
                UIErrorHelper.ShowAlert(exception.Message, "Error");
            }
        }