示例#1
0
        /// <summary>
        /// Retrns the certificates for a subjectName.
        /// </summary>
        /// <param name="subjectName">The subject name to lookup for certificates</param>
        /// <returns>The <see cref="X509Certificate2Collection"/> for the subject, or <c>null</c>
        /// if none are found.</returns>
        public X509Certificate2Collection this[string subjectName]
        {
            get
            {
                CertificateDictionary index = m_certIndex;

                X509Certificate2Collection matches;
                if (!index.TryGetValue(subjectName, out matches))
                {
                    matches = null;
                }
                return(matches);
            }
        }
示例#2
0
        CertificateDictionary Load(IEnumerable <X509Certificate2> certs)
        {
            CertificateDictionary certIndex = new CertificateDictionary();

            if (certs != null)
            {
                foreach (X509Certificate2 cert in certs)
                {
                    string name = cert.ExtractEmailNameOrName();
                    X509Certificate2Collection list = null;
                    if (!certIndex.TryGetValue(name, out list))
                    {
                        list            = new X509Certificate2Collection();
                        certIndex[name] = list;
                    }
                    list.Add(cert);
                }
            }
            //
            // Make the index readonly
            //
            return(certIndex);
        }
示例#3
0
        /// <summary>
        /// Refreshes the index (if the underlying store has changed).
        /// </summary>
        public void Refresh()
        {
            CertificateDictionary newIndex = this.Load(m_store);

            Interlocked.Exchange(ref m_certIndex, newIndex);
        }