Exemplo n.º 1
0
        private static void SetUMCertificate(X509Certificate2 cert, Server server, IConfigurationSession dataSession, bool allowConfirmation, Dictionary <AllowedServices, LocalizedString> confirmationStrings, List <LocalizedString> warningList)
        {
            UMServer umserver = new UMServer(server);

            if (!server.IsUnifiedMessagingServer)
            {
                throw new UMRoleNotInstalledException(cert.Thumbprint, server.Name);
            }
            if (umserver.UMStartupMode == UMStartupMode.TCP)
            {
                throw new CannotAssignCertificateToUMException(cert.Thumbprint);
            }
            if (CertificateUtils.IsExpired(cert))
            {
                throw new CertificateExpiredException(cert.Thumbprint);
            }
            if (allowConfirmation)
            {
                confirmationStrings[AllowedServices.UM] = Strings.ConfirmEnableCertForUM(cert.Thumbprint);
                return;
            }
            bool flag = false;

            if (string.IsNullOrEmpty(umserver.UMCertificateThumbprint))
            {
                flag = true;
            }
            ManageExchangeCertificate.CopyCertToRootStoreIfNeeded(cert, server);
            umserver.UMCertificateThumbprint = cert.Thumbprint;
            dataSession.Save(server);
            if (warningList != null && flag)
            {
                warningList.Add(Strings.ExchangeCertificateUpdatedForUM(server.Name));
            }
        }