private void btnCreateVerificationFile_Click(object sender, EventArgs e) { try { string tmpPath = Path.Combine(tbPath.Text, "files"); // Create a clean dir, if not able to delete then simply continue try { if (Directory.Exists(tmpPath)) { Directory.Delete(tmpPath, true); } } catch { MessageBox.Show(this, "Could not prepare 'files' directory. \nMake sure you close all windows previously opened by \nthis operation then try again.\nPath: " + tmpPath); return; } Directory.CreateDirectory(tmpPath); string rawUrl = tbFileServerPath.Text; Uri url = new Uri(rawUrl, UriKind.Absolute); string fullFilePath = Path.Combine(tmpPath, url.AbsolutePath.TrimStart('/').Replace('/', '\\')); Directory.CreateDirectory(Path.GetDirectoryName(fullFilePath)); CreateFileWithContents(fullFilePath, tbFileContents.Text); Process.Start(tmpPath); picVerificationFileStatus.Image = ResourceStream.GetImage(ResourceStream.Ok); lblVerificationFileStatus.Text = "Success"; ShowBalloonTip("Verification file created", btnCreateVerificationFile, 1000); } catch (Exception ex) { picVerificationFileStatus.Image = ResourceStream.GetImage(ResourceStream.Error); lblVerificationFileStatus.Text = ex.Message; } }
private void btnCreateDomainKey_Click(object sender, EventArgs e) { try { string tmpPath = Path.Combine(tbPath.Text, "tmp"); // Create a clean dir if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } string domainKey = Path.Combine(tbPath.Text, tbDomainKey.Text); string certSignFile = Path.Combine(tbPath.Text, tbOpenSSLCertCreationFile.Text); string openSSLPath = tbOpenSSLPath.Text; var batFileFullPath = Path.Combine(tmpPath, "run.bat"); // Create batch file with contents string winCommand = "\"" + openSSLPath + "\" genrsa 4096 > \"" + domainKey + "\""; CreateFileWithContents(batFileFullPath, winCommand); RunExternalExe(batFileFullPath); string rawCertData = GetCertificateSigningRequest(domainKey, certSignFile); tbCertSigningRequestContents.Text = rawCertData; Clipboard.SetText(rawCertData); ValidateTabPage1DomainKey(); ShowBalloonTip("Domain key created and copied to clipboard", btnCreateDomainKey, 1000); } catch (Exception ex) { picDomainKeyStatus.Image = ResourceStream.GetImage(ResourceStream.Error); lblDomainKeyStatus.Text = ex.Message; } }
private void btnCreateAccountKey_Click(object sender, EventArgs e) { try { string tmpPath = Path.Combine(tbPath.Text, "tmp"); // Create a clean dir if (!Directory.Exists(tmpPath)) { Directory.CreateDirectory(tmpPath); } string accountKey = Path.Combine(tbPath.Text, tbAccountKey.Text); string openSSLPath = tbOpenSSLPath.Text; var batFileFullPath = Path.Combine(tmpPath, "run.bat"); // Create batch file with contents string winCommand = "\"" + openSSLPath + "\" genrsa 4096 > \"" + accountKey + "\""; CreateFileWithContents(batFileFullPath, winCommand); RunExternalExe(batFileFullPath); string rawKeyData = GetKeyFileContents(accountKey); tbAccountKeyContents.Text = rawKeyData; Clipboard.SetText(rawKeyData); ValidateTabPage1AccountKey(); ShowBalloonTip("Account key created and copied to clipboard", btnCreateAccountKey, 1000); } catch (Exception ex) { picAccountKeyStatus.Image = ResourceStream.GetImage(ResourceStream.Error); lblAccountKeyStatus.Text = ex.Message; } }
private void ValidateSetupTab() { // Load values from settings if nothing is set if (string.IsNullOrWhiteSpace(tbOpenSSLPath.Text)) { tbOpenSSLPath.Text = Settings.Default.OpenSSLPath; } if (string.IsNullOrWhiteSpace(tbPath.Text)) { tbPath.Text = Settings.Default.LastWorkingPath; } var openSSLPathExists = File.Exists(tbOpenSSLPath.Text); var workingPathExists = Directory.Exists(tbPath.Text); picOKOpenSSL.Image = openSSLPathExists ? ResourceStream.GetImage(ResourceStream.Ok) : ResourceStream.GetImage(ResourceStream.Error); picOKWorkingPath.Image = workingPathExists ? ResourceStream.GetImage(ResourceStream.Ok) : ResourceStream.GetImage(ResourceStream.Error); picOKCertificateCreationFile.Image = File.Exists(Path.Combine(tbPath.Text, tbOpenSSLCertCreationFile.Text)) ? ResourceStream.GetImage(ResourceStream.Ok) : ResourceStream.GetImage(ResourceStream.Error); picOKAccountKey.Image = !string.IsNullOrWhiteSpace(tbAccountKey.Text) ? ResourceStream.GetImage(ResourceStream.Ok) : ResourceStream.GetImage(ResourceStream.Error); picOKDomainKey.Image = !string.IsNullOrWhiteSpace(tbDomainKey.Text) ? ResourceStream.GetImage(ResourceStream.Ok) : ResourceStream.GetImage(ResourceStream.Error); // Save settings for next use if (openSSLPathExists) { Settings.Default.OpenSSLPath = tbOpenSSLPath.Text; } if (workingPathExists) { Settings.Default.LastWorkingPath = tbPath.Text; } if (openSSLPathExists || workingPathExists) { Settings.Default.Save(); } }