public void CanAttachCTLToSSLInfo() { var testEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2924); CTLContextBuilder builder = new CTLContextBuilder(); builder.CTLInfo.ListIdentifier = "my test list binding"; builder.CTLInfo.Certificates.Add(Verisign); builder.CTLInfo.Certificates.Add(KisaRoot1); builder.Signers.Add(TestCertificate); HttpAPIManager manager = new HttpAPIManager(); var context = builder.ToCTLContext(); try { context.ImportInStore(StoreLocation.LocalMachine, StoreName.Root); SSLInfo info = new SSLInfo(); info.CheckClientCertificate = false; info.NegotiateClientCert = true; info.CTLIdentifier = context.CTLInfo.ListIdentifier; info.CTLStoreName = StoreName.Root; info.Certificate = TestCertificate; manager.SetSSLInfo(testEndpoint, info); } finally { context.RemoveFromStore(StoreLocation.LocalMachine, StoreName.Root); manager.RemoveSSLInfo(testEndpoint); } }
internal void CreateAndImportCTL(CTLContextBuilder builder) { if (String.IsNullOrEmpty(builder.CTLInfo.ListIdentifier)) { builder.CTLInfo.ListIdentifier = "New CTL"; } using (var context = builder.ToCTLContext()) { ImportCTL(context); } }
public void CanCreateSerializeAndReloadCTLContext() { var ctlBuilder = new CTLContextBuilder(); ctlBuilder.CTLInfo.Certificates.Add(TestCertificate); ctlBuilder.CTLInfo.ListIdentifier = "test list"; var ctlContext = ctlBuilder.ToCTLContext(); Assert.Equal("test list", ctlContext.FriendlyName); var bytes = ctlContext.ToBytes(); var loadedCtlContext = CTLContext.Load(bytes); Assert.Equal("test list", loadedCtlContext.FriendlyName); AssertCollectionEquals(TestCertificate.GetCertHash(), loadedCtlContext.CTLInfo.Entries[0].SubjectIdentifier); }
private void Create_CTL(object sender, RoutedEventArgs e) { if (ViewModel.CTLStoreNameProxy.store == null) { return; } CreateCTLWizard wizard = new CreateCTLWizard(); CTLContextBuilder builder = new CTLContextBuilder(); builder.CTLInfo.ListIdentifier = "New CTL"; wizard.DataContext = builder; var result = wizard.ShowDialog(); if (result.HasValue && result.Value) { ViewModel.CreateAndImportCTL(builder); } }
public void CanImportLoadThenDeleteCTLInStore() { var ctlBuilder = new CTLContextBuilder(); ctlBuilder.CTLInfo.Certificates.Add(TestCertificate); ctlBuilder.CTLInfo.ListIdentifier = "test list import"; var ctlContext = ctlBuilder.ToCTLContext(); ctlContext.ImportInStore(StoreLocation.CurrentUser, StoreName.My); try { Assert.NotNull(CTLContext.Get(StoreLocation.CurrentUser, StoreName.My, "test list import")); ctlContext.RemoveFromStore(StoreLocation.CurrentUser, StoreName.My); Assert.Null(CTLContext.Get(StoreLocation.CurrentUser, StoreName.My, "test list import")); ctlContext.RemoveFromStore(StoreLocation.CurrentUser, StoreName.My); //Does not throw if does not exist } finally { ctlContext.RemoveFromStore(StoreLocation.CurrentUser, StoreName.My); } }
private void CreateCTLClick(object sender, RoutedEventArgs e) { CreateCTLWizard wizard = new CreateCTLWizard(); var builder = new CTLContextBuilder(); builder.CTLInfo.ListIdentifier = "New CTL"; wizard.DataContext = builder; var result = wizard.ShowDialog(); if (result.HasValue && result.Value) { SaveFileDialog save = new SaveFileDialog(); var name = builder.CTLInfo.ListIdentifier; save.FileName = (String.IsNullOrEmpty(name) ? DefaultFileName : name) + ".stl"; var saveResult = save.ShowDialog(); if (saveResult.HasValue && saveResult.Value) { using (var context = builder.ToCTLContext()) { File.WriteAllBytes(save.FileName, context.ToBytes()); } } } }