// Token: 0x06001C2A RID: 7210 RVA: 0x0006F4BC File Offset: 0x0006D6BC public ChainValidityStatus ValidateCertificate(X509Certificate2 certificate, bool isSend) { this.response.PolicyFlag = 0U; this.response.ChainData = null; ChainContext chainContext = null; ChainValidityStatus chainValidityStatus; try { X509KeyUsageFlags expectedUsage = X509KeyUsageFlags.NonRepudiation | X509KeyUsageFlags.DigitalSignature; bool checkCRLOnSend = this.smimeAdminOptions.CheckCRLOnSend; bool disableCRLCheck = this.smimeAdminOptions.DisableCRLCheck; uint crlconnectionTimeout = this.smimeAdminOptions.CRLConnectionTimeout; uint crlretrievalTimeout = this.smimeAdminOptions.CRLRetrievalTimeout; bool flag = disableCRLCheck || (isSend && !checkCRLOnSend); if (string.IsNullOrEmpty(this.smimeAdminOptions.SMIMECertificateIssuingCAFull)) { bool enabled = VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled; if (enabled) { chainValidityStatus = (ChainValidityStatus)2148204809U; this.response.PolicyFlag = 65536U; } else { chainValidityStatus = X509CertificateCollection.ValidateCertificate(certificate, null, expectedUsage, !flag, null, null, TimeSpan.FromMilliseconds(crlconnectionTimeout), TimeSpan.FromMilliseconds(crlretrievalTimeout), ref chainContext, false, null); this.response.PolicyFlag = (uint)this.MapChainStatusToChainFlag(chainValidityStatus); } } else { X509Store x509Store = CertificateStore.Open(StoreType.Memory, null, OpenFlags.ReadWrite); X509Certificate2Collection x509Certificate2Collection = new X509Certificate2Collection(); x509Certificate2Collection.Import(Convert.FromBase64String(this.smimeAdminOptions.SMIMECertificateIssuingCAFull)); x509Store.AddRange(x509Certificate2Collection); chainValidityStatus = X509CertificateCollection.ValidateCertificate(certificate, null, expectedUsage, !flag, x509Store, null, TimeSpan.FromMilliseconds(crlconnectionTimeout), TimeSpan.FromMilliseconds(crlretrievalTimeout), ref chainContext, true, base.CallContext.AccessingPrincipal.MailboxInfo.OrganizationId.ToString()); this.response.PolicyFlag = (uint)this.MapChainStatusToChainFlag(chainValidityStatus); } if (!isSend) { this.response.DisplayedId = this.GetIdFromCertificate(certificate); if (this.response.DisplayedId == null) { chainValidityStatus = ChainValidityStatus.SubjectMismatch; } this.response.DisplayName = X509PartialCertificate.GetDisplayName(certificate); this.response.Issuer = this.GetIssuerDisplayNameFromCertificate(certificate); } } finally { if (chainContext != null) { chainContext.Dispose(); } } this.response.ChainValidityStatus = (uint)chainValidityStatus; return(chainValidityStatus); }
internal void BuildXmlResponse(XmlDocument xmlResponse, XmlNode parentNode, bool pictureLimitReached, out bool pictureWasAdded) { pictureWasAdded = false; XmlNode xmlNode = xmlResponse.CreateElement("Recipient", "ResolveRecipients:"); parentNode.AppendChild(xmlNode); XmlNode xmlNode2 = xmlResponse.CreateElement("Type", "ResolveRecipients:"); xmlNode2.InnerText = ((this.ResolvedTo.AddressOrigin == AddressOrigin.Directory) ? "1" : "2"); xmlNode.AppendChild(xmlNode2); XmlNode xmlNode3 = xmlResponse.CreateElement("DisplayName", "ResolveRecipients:"); xmlNode3.InnerText = this.ResolvedTo.DisplayName; xmlNode.AppendChild(xmlNode3); XmlNode xmlNode4 = xmlResponse.CreateElement("EmailAddress", "ResolveRecipients:"); xmlNode4.InnerText = this.ResolvedTo.SmtpAddress; xmlNode.AppendChild(xmlNode4); if (this.PictureOptions != null) { StatusCode statusCode = StatusCode.Success; byte[] array = null; if (Command.CurrentCommand.User.Features.IsEnabled(EasFeature.HDPhotos) && Command.CurrentCommand.Request.Version >= 160) { ResolveRecipientsCommand resolveRecipientsCommand = Command.CurrentCommand as ResolveRecipientsCommand; if (resolveRecipientsCommand != null && resolveRecipientsCommand.PhotoRetriever != null) { array = resolveRecipientsCommand.PhotoRetriever.EndGetThumbnailPhotoFromMailbox(this.ResolvedTo.SmtpAddress, GlobalSettings.MaxRequestExecutionTime - ExDateTime.Now.Subtract(Command.CurrentCommand.Context.RequestTime), this.PictureOptions.PhotoSize); } else { AirSyncDiagnostics.TraceError <string>(ExTraceGlobals.RequestsTracer, this, "Error getting PhotoRetriever instance from Command. Command:{0}", (Command.CurrentCommand == null) ? "<null>" : Command.CurrentCommand.Request.CommandType.ToString()); } } if (statusCode != StatusCode.Success || array == null) { array = this.Picture; } XmlNode newChild = this.PictureOptions.CreatePictureNode(xmlNode.OwnerDocument, "ResolveRecipients:", array, pictureLimitReached, out pictureWasAdded); xmlNode.AppendChild(newChild); } if (this.CertificateRetrieval != ResolveRecipientsCommand.CertificateRetrievalType.None) { XmlNode xmlNode5 = xmlResponse.CreateElement("Certificates", "ResolveRecipients:"); xmlNode.AppendChild(xmlNode5); XmlNode xmlNode6 = xmlResponse.CreateElement("Status", "ResolveRecipients:"); xmlNode5.AppendChild(xmlNode6); if (!this.GlobalCertLimitWasHit && (this.Certificates == null || this.Certificates.Count == 0)) { xmlNode6.InnerText = 7.ToString(CultureInfo.InvariantCulture); } else { if (this.GlobalCertLimitWasHit) { xmlNode6.InnerText = 8.ToString(CultureInfo.InvariantCulture); } else { xmlNode6.InnerText = 1.ToString(CultureInfo.InvariantCulture); } XmlNode xmlNode7 = xmlResponse.CreateElement("CertificateCount", "ResolveRecipients:"); xmlNode7.InnerText = this.CertificateCount.ToString(CultureInfo.InvariantCulture); xmlNode5.AppendChild(xmlNode7); XmlNode xmlNode8 = xmlResponse.CreateElement("RecipientCount", "ResolveRecipients:"); xmlNode8.InnerText = this.CertificateRecipientCount.ToString(CultureInfo.InvariantCulture); xmlNode5.AppendChild(xmlNode8); if (this.CertificateRetrieval == ResolveRecipientsCommand.CertificateRetrievalType.Full) { foreach (X509Certificate2 x509Certificate in this.Certificates) { XmlNode xmlNode9 = xmlResponse.CreateElement("Certificate", "ResolveRecipients:"); xmlNode9.InnerText = Convert.ToBase64String(x509Certificate.RawData); xmlNode5.AppendChild(xmlNode9); } } else { foreach (X509Certificate2 certificate in this.Certificates) { XmlNode xmlNode10 = xmlResponse.CreateElement("MiniCertificate", "ResolveRecipients:"); byte[] inArray = X509PartialCertificate.Encode(certificate, true); xmlNode10.InnerText = Convert.ToBase64String(inArray); xmlNode5.AppendChild(xmlNode10); } } } } if (this.AvailabilityStatus != StatusCode.None) { XmlNode xmlNode11 = xmlResponse.CreateElement("Availability", "ResolveRecipients:"); xmlNode.AppendChild(xmlNode11); XmlNode xmlNode12 = xmlResponse.CreateElement("Status", "ResolveRecipients:"); xmlNode12.InnerText = ((int)this.AvailabilityStatus).ToString(CultureInfo.InvariantCulture); xmlNode11.AppendChild(xmlNode12); if (!string.IsNullOrEmpty(this.MergedFreeBusy)) { XmlNode xmlNode13 = xmlResponse.CreateElement("MergedFreeBusy", "ResolveRecipients:"); xmlNode13.InnerText = this.MergedFreeBusy; xmlNode11.AppendChild(xmlNode13); return; } if (this.AvailabilityStatus == StatusCode.Success) { throw new InvalidOperationException("Empty free busy string received!"); } } }
// Token: 0x06001C2D RID: 7213 RVA: 0x0006F8E4 File Offset: 0x0006DAE4 internal string GetIdFromCertificate(X509Certificate2 certificate) { string emailAdress = X509PartialCertificate.GetEmailAdress(certificate); if (!string.IsNullOrEmpty(emailAdress)) { return(emailAdress); } string senderCertificateAttributesToDisplay = this.smimeAdminOptions.SenderCertificateAttributesToDisplay; if (string.IsNullOrEmpty(senderCertificateAttributesToDisplay)) { return(null); } IList <KeyValuePair <Oid, string> > list = X500DistinguishedNameDecoder.Decode(certificate.SubjectName); if (list == null || list.Count == 0) { return(null); } StringBuilder stringBuilder = null; string[] array = this.smimeAdminOptions.SenderCertificateAttributesToDisplay.Split(GetCertsInfo.comma, StringSplitOptions.RemoveEmptyEntries); bool flag = true; bool flag2 = false; foreach (string text in array) { string text2 = text.Trim(); if (!string.IsNullOrEmpty(text2)) { Oid oid = new Oid(text2); flag2 = false; foreach (KeyValuePair <Oid, string> keyValuePair in list) { if (string.Equals(keyValuePair.Key.Value, oid.Value, StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(keyValuePair.Value)) { if (stringBuilder == null) { stringBuilder = new StringBuilder(); } if (!flag) { stringBuilder.Append(", "); } else { flag = false; } stringBuilder.Append(keyValuePair.Value); flag2 = true; break; } } if (!flag2) { return(null); } } } if (stringBuilder == null) { return(null); } return(stringBuilder.ToString()); }