示例#1
0
        internal static List <KeyVaultCertificate> FromCertificateBundles(IEnumerable <CertificateBundle> certificateBundles)
        {
            if (certificateBundles == null || certificateBundles.Count() == 0)
            {
                return(null);
            }

            return(certificateBundles.Select(certificateBundle => KeyVaultCertificate.FromCertificateBundle(certificateBundle)).ToList());
        }
示例#2
0
        internal static KeyVaultCertificate FromCertificateBundle(CertificateBundle certificateBundle)
        {
            if (certificateBundle == null)
            {
                return(null);
            }

            var kvCertificate = new KeyVaultCertificate();

            if (certificateBundle.Id != null)
            {
                kvCertificate.Id   = certificateBundle.CertificateIdentifier.Identifier;
                kvCertificate.Name = certificateBundle.CertificateIdentifier.Name;
            }

            if (certificateBundle.Cer != null)
            {
                kvCertificate.Certificate = new X509Certificate2(certificateBundle.Cer);
                kvCertificate.Thumbprint  = kvCertificate.Certificate.Thumbprint;
            }

            if (certificateBundle.KeyIdentifier != null)
            {
                kvCertificate.KeyId = certificateBundle.KeyIdentifier.Identifier;
            }

            if (certificateBundle.SecretIdentifier != null)
            {
                kvCertificate.SecretId = certificateBundle.SecretIdentifier.Identifier;
            }

            if (certificateBundle.Attributes != null)
            {
                kvCertificate.Created = certificateBundle.Attributes.Created;
                kvCertificate.Enabled = certificateBundle.Attributes.Enabled;
                kvCertificate.Updated = certificateBundle.Attributes.Updated;
            }

            if (certificateBundle.Tags != null)
            {
                kvCertificate.Tags = certificateBundle.Tags;
            }

            return(kvCertificate);
        }
        internal static KeyVaultCertificate FromCertificateBundle(CertificateBundle certificateBundle)
        {
            if (certificateBundle == null)
            {
                return null;
            }

            var kvCertificate = new KeyVaultCertificate();

            if (certificateBundle.Id != null)
            {
                kvCertificate.Id = certificateBundle.CertificateIdentifier.Identifier;
                kvCertificate.Name = certificateBundle.CertificateIdentifier.Name;
            }

            if (certificateBundle.Cer != null)
            {
                kvCertificate.Certificate = new X509Certificate2(certificateBundle.Cer);
                kvCertificate.Thumbprint = kvCertificate.Certificate.Thumbprint;
            }

            if (certificateBundle.KeyIdentifier != null)
            {
                kvCertificate.KeyId = certificateBundle.KeyIdentifier.Identifier;
            }

            if (certificateBundle.SecretIdentifier != null)
            {
                kvCertificate.SecretId = certificateBundle.SecretIdentifier.Identifier;
            }

            if (certificateBundle.Attributes != null)
            {
                kvCertificate.Created = certificateBundle.Attributes.Created;
                kvCertificate.Enabled = certificateBundle.Attributes.Enabled;
                kvCertificate.Updated = certificateBundle.Attributes.Updated;
            }

            if (certificateBundle.Tags != null)
            {
                kvCertificate.Tags = certificateBundle.Tags;
            }

            return kvCertificate;
        }