Exemple #1
0
        internal /*for test only*/ static X509Certificate2?LoadFirstCertificate(IEnumerable <CertificateDescription> certificateDescription)
        {
            DefaultCertificateLoader defaultCertificateLoader = new DefaultCertificateLoader();
            CertificateDescription   certDescription          = certificateDescription.First();

            defaultCertificateLoader.LoadIfNeeded(certDescription);
            return(certDescription.Certificate);
        }
Exemple #2
0
        internal /*for test only*/ static IEnumerable <X509Certificate2?> LoadAllCertificates(IEnumerable <CertificateDescription> certificateDescriptions)
        {
            DefaultCertificateLoader defaultCertificateLoader = new DefaultCertificateLoader();

            foreach (var certDescription in certificateDescriptions)
            {
                defaultCertificateLoader.LoadIfNeeded(certDescription);
                yield return(certDescription.Certificate);
            }
        }
        /// <summary>
        /// Load the first certificate from the certificate description list.
        /// </summary>
        /// <param name="certificateDescriptions">Description of the certificates.</param>
        /// <returns>First certificate in the certificate description list.</returns>
        public static X509Certificate2?LoadFirstCertificate(IEnumerable <CertificateDescription> certificateDescriptions)
        {
            DefaultCertificateLoader defaultCertificateLoader = new DefaultCertificateLoader();
            CertificateDescription?  certDescription          = certificateDescriptions.FirstOrDefault(c =>
            {
                defaultCertificateLoader.LoadIfNeeded(c);
                return(c.Certificate != null);
            });

            return(certDescription?.Certificate);
        }
        /// <summary>
        /// Load all the certificates from the certificate description list.
        /// </summary>
        /// <param name="certificateDescriptions">Description of the certificates.</param>
        /// <returns>All the certificates in the certificate description list.</returns>
        public static IEnumerable <X509Certificate2?> LoadAllCertificates(IEnumerable <CertificateDescription> certificateDescriptions)
        {
            DefaultCertificateLoader defaultCertificateLoader = new DefaultCertificateLoader();

            if (certificateDescriptions != null)
            {
                foreach (var certDescription in certificateDescriptions)
                {
                    defaultCertificateLoader.LoadIfNeeded(certDescription);
                    if (certDescription.Certificate != null)
                    {
                        yield return(certDescription.Certificate);
                    }
                }
            }
        }