Ejemplo n.º 1
0
        public void TestFromPath(string certificatePath, string password)
        {
            CertificateDescription certificateDescription = CertificateDescription.FromPath(certificatePath, password);

            Assert.Equal(CertificateSource.Path, certificateDescription.SourceType);
            Assert.Equal(certificatePath, certificateDescription.Container);
            Assert.Equal(password, certificateDescription.ReferenceOrValue);
            Assert.Equal(certificatePath, certificateDescription.CertificateDiskPath);
            Assert.Equal(password, certificateDescription.CertificatePassword);
        }
        public void TestDefaultCertificateLoader(CertificateSource certificateSource, string container, string referenceOrValue)
        {
            CertificateDescription certificateDescription;

            switch (certificateSource)
            {
            case CertificateSource.KeyVault:
                certificateDescription = CertificateDescription.FromKeyVault(container, referenceOrValue);
                break;

            case CertificateSource.Base64Encoded:
                certificateDescription = CertificateDescription.FromBase64Encoded(referenceOrValue);
                break;

            case CertificateSource.Path:
                certificateDescription = CertificateDescription.FromPath(container, referenceOrValue);
                break;

            case CertificateSource.StoreWithThumbprint:
                certificateDescription = new CertificateDescription()
                {
                    SourceType = CertificateSource.StoreWithThumbprint
                };
                certificateDescription.CertificateThumbprint = referenceOrValue;
                certificateDescription.CertificateStorePath  = container;
                break;

            case CertificateSource.StoreWithDistinguishedName:
                certificateDescription = new CertificateDescription()
                {
                    SourceType = CertificateSource.StoreWithDistinguishedName
                };
                certificateDescription.CertificateDistinguishedName = referenceOrValue;
                certificateDescription.CertificateStorePath         = container;
                break;

            default:
                certificateDescription = null;
                break;
            }

            ICertificateLoader loader = new DefaultCertificateLoader();

            loader.LoadIfNeeded(certificateDescription);

            Assert.NotNull(certificateDescription.Certificate);
        }