public void LogCertificate(EdgeSyncLoggingLevel level, EdgeSyncEvent logEvent, X509Certificate2 cert) { if (cert == null) { return; } if (!this.CanLogEvent(level)) { return; } this.LogEvent(level, logEvent, cert.Subject, "Certificate subject"); this.LogEvent(level, logEvent, cert.IssuerName.Name, "Certificate issuer name"); this.LogEvent(level, logEvent, cert.SerialNumber, "Certificate serial number"); this.LogEvent(level, logEvent, cert.Thumbprint, "Certificate thumbprint"); StringBuilder stringBuilder = new StringBuilder(256); foreach (string value in TlsCertificateInfo.GetFQDNs(cert)) { if (stringBuilder.Length != 0) { stringBuilder.Append(';'); } stringBuilder.Append(value); } this.LogEvent(level, logEvent, stringBuilder.ToString(), "Certificate alternate names"); }
private static void SetPopImapCertificate(X509Certificate2 cert, PopImapAdConfiguration popImapAdConfiguration, IConfigurationSession dataSession, List <LocalizedString> warningList) { if (popImapAdConfiguration != null) { IList <string> fqdns = TlsCertificateInfo.GetFQDNs(cert); if (fqdns.Count == 0) { return; } popImapAdConfiguration.X509CertificateName = fqdns[0]; try { dataSession.Save(popImapAdConfiguration); } catch (DataValidationException) { if (warningList != null) { warningList.Add(Strings.WarnInvalidCertificateForProtocol(cert.Thumbprint, fqdns[0], popImapAdConfiguration.ProtocolName.Remove(popImapAdConfiguration.ProtocolName.Length - 1))); } } } }