private void createServerCertifiToolStripMenuItem_Click(object sender, EventArgs e) { CreateServerDialog dialog = new CreateServerDialog(); if (dialog.ShowDialog() == DialogResult.OK) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Save Server Certificate"; saveDialog.CheckPathExists = true; saveDialog.Filter = Files.CertificateFileFilter; if (saveDialog.ShowDialog() == DialogResult.OK) { ServerCertificate certificate = new ServerCertificate(dialog.FullName); certificate.CreateSelfSignature(); SignatureRequest request = new SignatureRequest(dialog.FullName, string.Empty, string.Empty); Secure<SignatureRequest> signedRequest = new Secure<SignatureRequest>(request, CaCertificate, certificate); CertificateAuthorityEntry entry = new CertificateAuthorityEntry(signedRequest); entry.Sign(CaCertificate, DateTime.Now, dialog.ValidUntil); certificate.AddSignature(entry.Response.Value.Signature); string entryFileName = DataPath(entry.Certificate.Id.ToString() + ".pi-ca-entry"); entry.Save(DataPath(entryFileName)); ListEntry listEntry = new ListEntry(entryFileName, entry, CaCertificate); Entries.Add(listEntry); this.entryListView.Items.Add(listEntry.CreateItem(CaCertificate)); certificate.Save(saveDialog.FileName); } } }
private void createAdminCertificateToolStripMenuItem_Click(object sender, EventArgs e) { CreateAdminDialog dialog = new CreateAdminDialog(); if (dialog.ShowDialog() == DialogResult.OK) { SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.Title = "Save Admin Certificate"; saveDialog.CheckPathExists = true; saveDialog.Filter = Files.CertificateFileFilter; if (saveDialog.ShowDialog() == DialogResult.OK) { string fullName = string.Format("{0} {1}, {2}", dialog.FirstName, dialog.FamilyName, dialog.Function); AdminCertificate certificate = new AdminCertificate(Language.English, dialog.Passphrase, fullName); certificate.CreateSelfSignature(); SignatureRequest request = new SignatureRequest(dialog.FirstName, dialog.FamilyName, dialog.EmailAddress); Secure<SignatureRequest> signedRequest = new Secure<SignatureRequest>(request, CaCertificate, certificate); CertificateAuthorityEntry entry = new CertificateAuthorityEntry(signedRequest); entry.Sign(CaCertificate, DateTime.Now, dialog.ValidUntil); certificate.AddSignature(entry.Response.Value.Signature); string entryFileName = DataPath(entry.Certificate.Id.ToString() + ".pi-ca-entry"); entry.Save(DataPath(entryFileName)); ListEntry listEntry = new ListEntry(entryFileName, entry, CaCertificate); Entries.Add(listEntry); this.entryListView.Items.Add(listEntry.CreateItem(CaCertificate)); certificate.Save(saveDialog.FileName); } } }