private void ChooseKeyPairButton_Click(object sender, EventArgs e) { OpenDialog.Filter = ToolsHub.KeysFilter; if (OpenDialog.ShowDialog() == DialogResult.OK) { KeyPairFilenameBox.Text = OpenDialog.FileName; AsymmetricCipherKeyPair KeyPair = CryptoAdapter.LoadKeyPairFromDiskBouncy(KeyPairFilenameBox.Text); if (KeyPair == null) { MessageBox.Show("Unable to load key pair from disk, make sure it is in a supported format (xml or pkcs 12 key store)", Config.AppDisplayName, MessageBoxButtons.OK, MessageBoxIcon.Error); KeyPairFilenameBox.Text = ""; } } }
private void GenerateRequestButton_Click(object sender, EventArgs e) { if (EMailEditBox.Text == "") { MessageBox.Show("An Email address is required to generate a signing request", Config.AppDisplayName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (CommonNameEditBox.Text == "") { MessageBox.Show("A common name is required to generate a signing request", Config.AppDisplayName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AsymmetricCipherKeyPair KeyPair = null; try { KeyPair = CryptoAdapter.LoadKeyPairFromDiskBouncy(KeyPairFilenameBox.Text); if (KeyPair == null) { throw new InvalidDataException(); } } catch (Exception) { MessageBox.Show("A public/private key pair is required to generate a signing request (failed to find or open specified key pair file)", Config.AppDisplayName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SaveDialog.FileName = "CertificateSigningRequest.csr"; SaveDialog.DefaultExt = "csr"; SaveDialog.Filter = ToolsHub.CertificateRequestFilter; SaveDialog.Title = "Generate Certificate Signing Request"; if (SaveDialog.ShowDialog() == DialogResult.OK) { string EffectiveBuildPath = (Program.GameName.Length > 0) ? Config.BuildDirectory : Path.GetFullPath("."); string TargetCertRequestFileName = SaveDialog.FileName; GenerateSigningRequestViaOpenSSL(TargetCertRequestFileName, KeyPair); //GenerateSigningRequestViaBouncyCastle(TargetCertRequestFileName, KeyPair); // Close this dialog Close(); } }