Example #1
0
 private bool CheckCertPrereqs()
 {
     if (!Configuration.DisableCertificateChecks)
     {
         foreach (ADObjectId adobjectId in this.SendingAndReceivingTransportServers)
         {
             IExchangeCertificate exchangeCertificate = base.OnPremisesSession.GetExchangeCertificate(adobjectId.Name, this.TlsCertificateName);
             if (exchangeCertificate == null)
             {
                 throw new LocalizedException(HybridStrings.ErrorSecureMailCertificateNotFound(this.HybridConfiguration.TlsCertificateName.CertificateSubject, this.HybridConfiguration.TlsCertificateName.CertificateIssuer, adobjectId.Name));
             }
             if (!exchangeCertificate.Services.ToString().ToUpper().Contains(AllowedServices.SMTP.ToString()))
             {
                 throw new LocalizedException(HybridStrings.ErrorSecureMailCertificateNoSmtp(adobjectId.Name));
             }
             if (exchangeCertificate.IsSelfSigned)
             {
                 throw new LocalizedException(HybridStrings.ErrorSecureMailCertificateSelfSigned(adobjectId.Name));
             }
             if (exchangeCertificate.NotBefore > (DateTime)ExDateTime.Now || exchangeCertificate.NotAfter < (DateTime)ExDateTime.Now)
             {
                 throw new LocalizedException(HybridStrings.ErrorSecureMailCertificateInvalidDate(adobjectId.Name));
             }
         }
     }
     return(true);
 }