public void CreateSignedBundleTest() { //Arrange Bundler bundle = new Bundler(); const string outputFileName = @"TestBundleWithMetadata.p7m"; var secString = new SecureString(); foreach (var secchar in "passw0rd!".ToCharArray()) { secString.AppendChar(secchar); } //Act IResourceProvider resourceProvider = new FileResourceProvider( Path.Combine(Directory.GetCurrentDirectory(), _incominganchors) , Path.Combine(Directory.GetCurrentDirectory(), outputFileName)); ISignProvider signProvider = new FileSignerProvider( Path.Combine(Directory.GetCurrentDirectory(), _privateRedmondPfx), secString); byte[] cmsdata = bundle.Create(resourceProvider, signProvider); //Assert (Using agent bundler resolver code) Assert.Null(Record.Exception(() => resourceProvider.StoreBundle(cmsdata))); byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName)); AnchorBundle anchorBundle = null; Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(p7BData, true))); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.Null(anchorBundle.Metadata); }
public void CreateBundleTest() { //Arrange Bundler bundle = new Bundler(); const string outputFileName = @"TestBundle.p7m"; //Act IResourceProvider resourceProvider = new FileResourceProvider( Path.Combine(Directory.GetCurrentDirectory() , _incominganchors) , Path.Combine(Directory.GetCurrentDirectory() , outputFileName)); byte[] cmsdata = bundle.Create(resourceProvider); //Assert (Using agent bundler resolver code) Assert.Null(Record.Exception(() => resourceProvider.StoreBundle(cmsdata))); byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName)); AnchorBundle anchorBundle = null; Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(p7BData))); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.Null(anchorBundle.Metadata); }
public void CreateBundleWithMetadataTest() { //Arrange Bundler bundle = new Bundler(); const string outputFileName = @"TestBundleWithMetadata.p7b"; //Act IResourceProvider resourceProvider = new FileResourceProvider(Path.Combine(Directory.GetCurrentDirectory() , _incominganchors), Path.Combine(Directory.GetCurrentDirectory(), outputFileName) , null , @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>"); byte[] cmsdata = bundle.Create(resourceProvider); //Assert (Using agent bundler resolver code) Assert.Null(Record.Exception(() => resourceProvider.StoreBundle(cmsdata))); byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName)); AnchorBundle anchorBundle = null; Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(p7BData))); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.NotNull(anchorBundle.Metadata); Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata); }
public void TestPEM() { byte[] p7bData = File.ReadAllBytes(@"Certificates\Bundles\bundlePEM.p7b"); AnchorBundle bundle = null; Assert.DoesNotThrow(() => bundle = new AnchorBundle(p7bData)); Assert.True(!bundle.Certificates.IsNullOrEmpty()); }
public void TestWithMetadata() { byte[] p7bData = File.ReadAllBytes(@"Certificates\Bundles\bundleWithMetadata.p7b"); AnchorBundle bundle = null; Assert.DoesNotThrow(() => bundle = new AnchorBundle(p7bData)); Assert.True(!bundle.Certificates.IsNullOrEmpty()); Assert.True(bundle.Certificates.Count == 2); Assert.True(!string.IsNullOrEmpty(bundle.Metadata)); }
public void TestNoMetadata() { byte[] p7bData = File.ReadAllBytes(@"Certificates\Bundles\bundleNoMetadata.p7b"); AnchorBundle bundle = null; Assert.Null(Record.Exception(() => bundle = new AnchorBundle(p7bData))); Assert.True(!bundle.Certificates.IsNullOrEmpty()); Assert.True(bundle.Certificates.Count == 2); Assert.True(string.IsNullOrEmpty(bundle.Metadata)); }
public void TestDownloadBundle() { AnchorBundleDownloader downloader = new AnchorBundleDownloader(); downloader.MaxRetries = 1; AnchorBundle bundle = null; Assert.DoesNotThrow(() => bundle = downloader.Download(new Uri(PatientTestBundleUrl))); Assert.True(!bundle.Certificates.IsNullOrEmpty()); }
public void TestSigned() { X509Certificate2 signingCert = AgentTester.LoadPrivateCerts("redmond").First(); X509Certificate2Collection certs = AgentTester.LoadPrivateCerts("nhind").GetAllCertificates(); byte[] p7sData = null; Assert.DoesNotThrow(() => p7sData = AnchorBundle.CreateSigned(certs, signingCert)); Assert.True(!p7sData.IsNullOrEmpty()); AnchorBundle bundle = null; Assert.DoesNotThrow(() => bundle = new AnchorBundle(p7sData, true)); Assert.True(!bundle.Certificates.IsNullOrEmpty()); Assert.True(certs.Count == bundle.Certificates.Count); }
public void CreateSignedBundleWithMetadataTest() { BundleAnchorsCommand cmd = new BundleAnchorsCommand(); string[] ignoreArray = new string[] { "Direct.Drhisp.Com Root CAKey.der" }; cmd.Name = @".\Certificates\nhind\IncomingAnchors"; cmd.Ignore = ignoreArray; cmd.Metadata = @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>"; IEnumerator result = cmd.Invoke().GetEnumerator(); result.MoveNext(); SignBundleCommand signCmd = new SignBundleCommand(); var secString = new SecureString(); foreach (var secchar in "passw0rd!".ToCharArray()) { secString.AppendChar(secchar); } signCmd.Name = @".\Certificates\redmond\Private\redmond.pfx"; signCmd.PassKey = secString; signCmd.Bundle = (byte[])result.Current; result = signCmd.Invoke().GetEnumerator(); result.MoveNext(); byte[] signedCmsdata = (byte[])result.Current; //Assert (Using agent bundler resolver code) AnchorBundle anchorBundle = null; Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(signedCmsdata, true)); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata); }
public void CreateBundleWithMetadataTest() { BundleAnchorsCommand cmd = new BundleAnchorsCommand(); string[] ignoreArray = new string[] { "Direct.Drhisp.Com Root CAKey.der" }; cmd.Name = _incominganchors; cmd.Ignore = ignoreArray; cmd.Metadata = @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>"; IEnumerator result = cmd.Invoke().GetEnumerator(); result.MoveNext(); byte[] cmsdata = (byte[])result.Current; //Assert (Using agent bundler resolver code) AnchorBundle anchorBundle = null; Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(cmsdata))); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata); }
public void CreateBundleTest() { BundleAnchorsCommand cmd = new BundleAnchorsCommand(); string[] ignoreArray = new string[] { "Direct.Drhisp.Com Root CAKey.der" }; cmd.Name = _incominganchors; cmd.Ignore = ignoreArray; IEnumerator result = cmd.Invoke().GetEnumerator(); result.MoveNext(); byte[] cmsdata = (byte[])result.Current; //Assert (Using agent bundler resolver code) AnchorBundle anchorBundle = null; Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(cmsdata))); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.Null(anchorBundle.Metadata); }
public void CreateSignedBundleWithMetadataTest() { //Arrange Bundler bundle = new Bundler(); const string outputFileName = @"TestBundleSignedWithMetadata.p7m"; var secString = new SecureString(); foreach (var secchar in "passw0rd!".ToCharArray()) { secString.AppendChar(secchar); } //Act IResourceProvider resourceProvider = new FileResourceProvider(Path.Combine(Directory.GetCurrentDirectory() , @"Certificates\nhind\IncomingAnchors"), Path.Combine(Directory.GetCurrentDirectory(), outputFileName) , null , @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>"); ISignProvider signProvider = new FileSignerProvider( Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"), secString); byte[] cmsdata = bundle.Create(resourceProvider, signProvider); //Assert (Using agent bundler resolver code) Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata)); byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName)); AnchorBundle anchorBundle = null; Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true)); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.NotNull(anchorBundle.Metadata); Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata); }
public void CreateSignedBundleIndependentTest() { //Arrange Bundler bundle = new Bundler(); const string outputFileName = @"TestBundleSignedIndependent.p7m"; var secString = new SecureString(); foreach (var secchar in "passw0rd!".ToCharArray()) { secString.AppendChar(secchar); } //Act IResourceProvider resourceProvider = new FileResourceProvider( Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\nhind\IncomingAnchors") , Path.Combine(Directory.GetCurrentDirectory(), outputFileName)); ISignProvider signProvider = new FileSignerProvider( Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"), secString); byte[] cmsdata = bundle.Create(resourceProvider); cmsdata = bundle.Sign(cmsdata, signProvider); //Assert (Using agent bundler resolver code) Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata)); byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName)); AnchorBundle anchorBundle = null; Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true)); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.Null(anchorBundle.Metadata); }
public void CreateSigneBundleTest() { BundleAnchorsCommand cmd = new BundleAnchorsCommand(); string[] ignoreArray = new string[] { "Direct.Drhisp.Com Root CAKey.der" }; cmd.Name = _incominganchors; cmd.Ignore = ignoreArray; IEnumerator result = cmd.Invoke().GetEnumerator(); result.MoveNext(); SignBundleCommand signCmd = new SignBundleCommand(); var secString = new SecureString(); foreach (var secchar in "passw0rd!".ToCharArray()) { secString.AppendChar(secchar); } signCmd.Name = _privateRedmondPfx; signCmd.PassKey = secString; signCmd.Bundle = (byte[])result.Current; result = signCmd.Invoke().GetEnumerator(); result.MoveNext(); byte[] signedCmsdata = (byte[])result.Current; //Assert (Using agent bundler resolver code) AnchorBundle anchorBundle = null; Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(signedCmsdata, true))); Assert.True(!anchorBundle.Certificates.IsNullOrEmpty()); Assert.Equal(4, anchorBundle.Certificates.Count); Assert.Null(anchorBundle.Metadata); }