public void DeleteHttpsBindings() { var logger = new TestLogsLogger(this, nameof(this.DeleteHttpsBindings)); using (ServerManager sm = new ServerManager()) { var site = sm.Sites.Add("site0", Path.GetTempPath(), 443); site.Bindings.Add("127.0.0.1:5879:site0", null, null, SslFlags.CentralCertStore | SslFlags.Sni); site.Bindings.Add("127.0.0.1:5879:site1", null, null, SslFlags.CentralCertStore | SslFlags.Sni); sm.CommitChanges(); } Thread.Sleep(500); var certificates = UtilsIis.GetBoundCertificates(); Assert.True(certificates.Any((i) => i.Attributes.Any((j) => j.Key == "Central Certificate Store" && j.Value == "5879"))); using (ServerManager sm = new ServerManager()) { var site = UtilsIis.FindSiteWithName(sm, "site0", logger).Single(); UtilsIis.RemoveSiteBindings(site, sm, (i) => i.Host == "site1", logger); sm.CommitChanges(); } certificates = UtilsIis.GetBoundCertificates(); Assert.True(certificates.Any((i) => i.Attributes.Any((j) => j.Key == "Central Certificate Store" && j.Value == "5879"))); using (ServerManager sm = new ServerManager()) { var site = UtilsIis.FindSiteWithName(sm, "site0", logger).Single(); UtilsIis.RemoveSiteBindings(site, sm, (i) => i.Host == "site0", logger); sm.CommitChanges(); } Thread.Sleep(500); certificates = UtilsIis.GetBoundCertificates(); Assert.False(certificates.Any((i) => i.Attributes.Any((j) => j.Key == "Central Certificate Store" && j.Value == "5879"))); using (ServerManager sm = new ServerManager()) { var site = UtilsIis.FindSiteWithName(sm, "site0", logger).Single(); site.Bindings.Add("127.0.0.1:5879:site0", null, null, SslFlags.CentralCertStore | SslFlags.Sni); site.Bindings.Add("127.0.0.1:5879:site1", null, null, SslFlags.CentralCertStore | SslFlags.Sni); sm.CommitChanges(); } Thread.Sleep(500); certificates = UtilsIis.GetBoundCertificates(); Assert.True(certificates.Any((i) => i.Attributes.Any((j) => j.Key == "Central Certificate Store" && j.Value == "5879"))); using (ServerManager sm = new ServerManager()) { var site = UtilsIis.FindSiteWithName(sm, "site0", logger).Single(); UtilsIis.RemoveSite(site, sm, logger); sm.CommitChanges(); } Thread.Sleep(500); certificates = UtilsIis.GetBoundCertificates(); Assert.False(certificates.Any((i) => i.Attributes.Any((j) => j.Key == "Central Certificate Store" && j.Value == "5879"))); }
public void ReadBoundCertificates() { var certificates = UtilsIis.GetBoundCertificates(); Assert.NotEmpty(certificates); }