// Token: 0x0600000A RID: 10 RVA: 0x000029E4 File Offset: 0x00000BE4
 private void PullCertificate(List <TopologyServer> sourceServers, List <CertificateRecord> certsNeeded, Server destinationServer)
 {
     foreach (TopologyServer topologyServer in sourceServers)
     {
         Servicelet.Tracer.TraceDebug <TopologyServer>((long)this.GetHashCode(), "Testing Server: {0}", topologyServer);
         if (!destinationServer.Id.Equals(topologyServer.Id))
         {
             List <CertificateRecord> list = new List <CertificateRecord>();
             foreach (CertificateRecord certificateRecord in certsNeeded)
             {
                 Servicelet.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Testing Cert: {0}", certificateRecord.Thumbprint);
                 SecureString securePassword = FederationCertificate.GeneratePassword();
                 try
                 {
                     string base64cert = FederationCertificate.ExportCertificate(topologyServer.Name, securePassword, certificateRecord.Thumbprint);
                     FederationCertificate.ImportCertificate(destinationServer.Name, securePassword, base64cert);
                     FederationCertificate.EnableCertificateForNetworkService(destinationServer.Name, certificateRecord.Thumbprint);
                     list.Add(certificateRecord);
                     this.eventLogger.LogEvent(MSExchangeCertificateDeploymentEventLogConstants.Tuple_InstalledCertificate, null, new object[]
                     {
                         certificateRecord,
                         topologyServer.Name
                     });
                 }
                 catch (LocalizedException arg)
                 {
                     Servicelet.Tracer.TraceError <LocalizedException>((long)this.GetHashCode(), "Failed to Export/Import: {0}", arg);
                 }
                 catch (InvalidOperationException arg2)
                 {
                     Servicelet.Tracer.TraceError <InvalidOperationException>((long)this.GetHashCode(), "Failed to Export/Import: {0}", arg2);
                 }
             }
             foreach (CertificateRecord certificateRecord2 in list)
             {
                 Servicelet.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Succesfully Retrieved: {0}", certificateRecord2.Thumbprint);
                 certsNeeded.Remove(certificateRecord2);
             }
             if (certsNeeded.Count == 0)
             {
                 break;
             }
         }
     }
 }
        // Token: 0x06000006 RID: 6 RVA: 0x000024D0 File Offset: 0x000006D0
        private void PerformDistribution(List <CertificateRecord> certsRequired)
        {
            Servicelet.Tracer.TraceDebug((long)this.GetHashCode(), "PerformDistribution(): Entering");
            List <CertificateRecord> list = new List <CertificateRecord>();

            foreach (CertificateRecord certificateRecord in certsRequired)
            {
                string thumbprint = certificateRecord.Thumbprint;
                Servicelet.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Certificate Required: {0}", thumbprint);
                ExchangeCertificate             exchangeCertificate;
                FederationTrustCertificateState federationTrustCertificateState = FederationCertificate.TestForCertificate(this.localServer.Name, thumbprint, out exchangeCertificate);
                Servicelet.Tracer.TraceDebug <FederationTrustCertificateState>((long)this.GetHashCode(), "Certificate State: {0}", federationTrustCertificateState);
                if (federationTrustCertificateState == FederationTrustCertificateState.NotInstalled)
                {
                    list.Add(certificateRecord);
                    if (this.IsCurrentOrNextCertificate(certificateRecord))
                    {
                        this.eventLogger.LogEvent(MSExchangeCertificateDeploymentEventLogConstants.Tuple_NeedCertificate, null, new object[]
                        {
                            thumbprint
                        });
                    }
                }
                else if (federationTrustCertificateState == FederationTrustCertificateState.Installed)
                {
                    if (this.IsCurrentOrNextCertificate(certificateRecord))
                    {
                        this.VerifyCertificateExpiration(exchangeCertificate);
                    }
                    if (!ManageExchangeCertificate.IsCertEnabledForNetworkService(exchangeCertificate))
                    {
                        Servicelet.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Enabling for Network Service: {0}", thumbprint);
                        try
                        {
                            FederationCertificate.EnableCertificateForNetworkService(this.localServer.Name, thumbprint);
                        }
                        catch (LocalizedException ex)
                        {
                            Servicelet.Tracer.TraceError <LocalizedException>((long)this.GetHashCode(), "Failed to Enable for Network Service: {0}", ex);
                            this.eventLogger.LogEvent(MSExchangeCertificateDeploymentEventLogConstants.Tuple_EnableNetworkServiceException, null, new object[]
                            {
                                thumbprint,
                                ex
                            });
                        }
                        catch (InvalidOperationException ex2)
                        {
                            Servicelet.Tracer.TraceError <InvalidOperationException>((long)this.GetHashCode(), "Failed to Enable for Network Service: {0}", ex2);
                            this.eventLogger.LogEvent(MSExchangeCertificateDeploymentEventLogConstants.Tuple_EnableNetworkServiceException, null, new object[]
                            {
                                thumbprint,
                                ex2
                            });
                        }
                    }
                }
            }
            if (list.Count != 0)
            {
                Dictionary <TopologySite, List <TopologyServer> > dictionary;
                TopologySite topologySite;
                FederationCertificate.DiscoverServers(this.session, true, out dictionary, out topologySite);
                if (topologySite == null)
                {
                    Servicelet.Tracer.TraceError((long)this.GetHashCode(), "Server is not associated with a site");
                    this.eventLogger.LogEvent(MSExchangeCertificateDeploymentEventLogConstants.Tuple_CannotFindLocalSite, null, null);
                    return;
                }
                List <TopologyServer> sourceServers;
                if (dictionary.TryGetValue(topologySite, out sourceServers))
                {
                    this.PullCertificate(sourceServers, list, this.localServer);
                }
                if (list.Count != 0)
                {
                    foreach (KeyValuePair <TopologySite, List <TopologyServer> > keyValuePair in dictionary)
                    {
                        if (!keyValuePair.Key.Equals(topologySite))
                        {
                            this.PullCertificate(keyValuePair.Value, list, this.localServer);
                            if (list.Count == 0)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            foreach (CertificateRecord certificateRecord2 in list)
            {
                Servicelet.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Certificate not found: {0}", certificateRecord2.Thumbprint);
                if (this.IsCurrentOrNextCertificate(certificateRecord2))
                {
                    this.eventLogger.LogEvent(MSExchangeCertificateDeploymentEventLogConstants.Tuple_CertificateNotFound, null, new object[]
                    {
                        certificateRecord2.Thumbprint
                    });
                }
            }
            Servicelet.Tracer.TraceDebug((long)this.GetHashCode(), "PerformDistribution(): Exiting");
        }