Exemplo n.º 1
0
        public void MyTestInitialize()
        {
            CACertificate rootCertificate = new CACertificate(null, "Root CA");
              rootCertificate.CreateSelfSignature();
              rootCertificate.Save("root.pi-cert");

              ServerCertificate serverCertificate = new ServerCertificate("Server");
              serverCertificate.CreateSelfSignature();
              serverCertificate.AddSignature(rootCertificate, DateTime.Now.AddDays(1));
              serverCertificate.Save("server.pi-cert");
        }
Exemplo n.º 2
0
        private void createToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CreateCaDialog dialog = new CreateCaDialog();

              if (dialog.ShowDialog() == DialogResult.OK)
              {
            if (dialog.RootCa)
            {
              CaCertificate = new CACertificate(dialog.Passphrase, dialog.CaName);
              CaCertificate.CreateSelfSignature();
              CaCertificate.Save(DataPath(CaCertFileName));
              CertificateStorage.AddRoot(CaCertificate.OnlyPublicPart);
              CertificateStorage.Save(DataPath(StorageFileName));
            }
            else
            {
              OpenFileDialog openDialog = new OpenFileDialog();
              openDialog.Title = "Open Root Certificate Authority Certificate";
              openDialog.CheckPathExists = true;
              openDialog.CheckFileExists = true;
              openDialog.Filter = Files.CertificateFileFilter;

              if (openDialog.ShowDialog() == DialogResult.OK)
              {
            CACertificate caCertificate = Serializable.Load<CACertificate>(openDialog.FileName);
            CertificateStorage.AddRoot(caCertificate);
            CaCertificate = new CACertificate(dialog.Passphrase, dialog.CaName);
            CaCertificate.CreateSelfSignature();
            CaCertificate.Save(DataPath(CaCertFileName));
            CertificateStorage.Add(CaCertificate.OnlyPublicPart);
            CertificateStorage.Save(DataPath(StorageFileName));
              }
            }
              }
        }