private void KeyLocationTriggerBtn_Click(object sender, RoutedEventArgs e) { _SELECTED_FOLDER_LOCATION = string.Empty; using FolderBrowserDialog _FodlerBrowserDialogue = new(); _FodlerBrowserDialogue.SelectedPath = OpenSSLEnvVarProvider.GetCurrentDirPath(); _ = _FodlerBrowserDialogue.ShowDialog(); _SELECTED_FOLDER_LOCATION = _FodlerBrowserDialogue.SelectedPath; _KeyLocationTF.Text = _SELECTED_FOLDER_LOCATION; }
private void GenerateKeyBtn_Click(object sender, RoutedEventArgs e) { if (!ValidateCreateCAKey()) { return; } if (!MatchRetypePassword()) { return; } // genrsa -des3 -passout pass:yourpassword -out /path/to/your/key_file 1024 // Process user inputs to create CA key string _OpenSSLUIPATHEnvVar = OpenSSLEnvVarProvider.GetOPENSSLUIPATHEnvVar(); if (string.IsNullOrEmpty(_OpenSSLUIPATHEnvVar)) { System.Windows.MessageBox.Show("OPENSSL_UI_PATH is not set, Please set the path before continue!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { // Variable is available, Run OpenSSL string _KeyName = _CaKeyNameTF.Text; string _KeyLocation = _KeyLocationTF.Text; string _BitLength = _BitLengthCmb.Text; string _Password = PasswordRetypeTF.Password; if (string.IsNullOrEmpty(_BitLength)) { _BitLength = OpenSSLConfig.DEFAULT_BIT_LENGTH; } string _InvocationParameters; // Flag to distinguise whether user has keyed in password fields if (PassPhraseProvided()) { // Execute openssl command to create a key with passphrase _InvocationParameters = COMMAND_GENRSA + " -aes128 -passout pass:"******" -out \"" + Path.Combine(_KeyLocation, _KeyName + " " + _BitLength) + "\""; } else { // Create a key without a passphase _InvocationParameters = COMMAND_GENRSA + " -out \"" + Path.Combine(_KeyLocation, _KeyName + " " + _BitLength) + "\""; } // Start an OpenSSL process with descriptive error if not found OpenSSL.TryOpenSSL(_InvocationParameters); } }
private void SelectCAKeyTriggerBtn_Click(object sender, RoutedEventArgs e) { _SELECTED_CA_KEY_FOLDER_LOCATION = string.Empty; using OpenFileDialog _CAFileDialogue = new(); _CAFileDialogue.InitialDirectory = OpenSSLEnvVarProvider.GetCurrentDirPath(); _ = _CAFileDialogue.ShowDialog(); string _CAKeyFileName = _CAFileDialogue.FileName; if (!string.IsNullOrEmpty(_CAKeyFileName)) { _SELECTED_CA_KEY_FOLDER_LOCATION = _CAKeyFileName; _SelectCAKeyLocationTF.Text = _SELECTED_CA_KEY_FOLDER_LOCATION; } }