├── PowerCSR_V1.ps1
└── README.md
/PowerCSR_V1.ps1:
--------------------------------------------------------------------------------
1 | ######################################################################################
2 | # PowerCSR V1.0 - Released 23/01/2024 #
3 | # #
4 | # Script Created by ReproDev: https://https://github.com/reprodev/PowerCSR/ #
5 | # Released Under MIT Licence #
6 | # Check out other projects : https://github.com/reprodev/ #
7 | # Why not buy me a coffee? : https://ko-fi.com/reprodev #
8 | # #
9 | ######################################################################################
10 |
11 | # Load Windows Forms
12 | Add-Type -AssemblyName System.Windows.Forms
13 |
14 | # Create the form
15 | $form = New-Object System.Windows.Forms.Form
16 | $form.Text = 'PowerCSR V1.0'
17 | $form.Size = New-Object System.Drawing.Size(650,630) # Increased size
18 |
19 | # Function to add a label and textbox
20 | function Add-InputField($form, $labelText, $position, $isPassword) {
21 | $label = New-Object System.Windows.Forms.Label
22 | $label.Location = New-Object System.Drawing.Point(15, $position)
23 | $label.Size = New-Object System.Drawing.Size(180, 40) # Increased size
24 | $label.Text = $labelText
25 | $label.Font = New-Object System.Drawing.Font("Arial", 12) # Increased font size for label
26 | $form.Controls.Add($label)
27 |
28 | $textBox = New-Object System.Windows.Forms.TextBox
29 | $textBox.Location = New-Object System.Drawing.Point(195, $position)
30 | $textBox.Size = New-Object System.Drawing.Size(395, 30) # Increased size
31 | $textBox.Font = New-Object System.Drawing.Font("Arial", 12) # Increased font size for input box
32 | if ($isPassword) { $textBox.UseSystemPasswordChar = $true }
33 | $form.Controls.Add($textBox)
34 |
35 | return $textBox
36 | }
37 |
38 | # Adding input fields with increased spacing
39 | $commonName = Add-InputField $form 'Common Name (CN):' 30 $false
40 | $organization = Add-InputField $form 'Organization (O):' 75 $false
41 | $organizationalUnit = Add-InputField $form 'Organizational Unit (OU):' 120 $false
42 | $country = Add-InputField $form 'Country (C):' 170 $false
43 | $state = Add-InputField $form 'State (ST):' 215 $false
44 | $locality = Add-InputField $form 'Locality (L):' 260 $false
45 | # $email = Add-InputField $form 'Email (Email):' 305 $false
46 | $password1 = Add-InputField $form 'Password:' 350 $true
47 | $password2 = Add-InputField $form 'Confirm Password:' 395 $true
48 |
49 | # Create a button with increased size
50 | $button = New-Object System.Windows.Forms.Button
51 | $button.Location = New-Object System.Drawing.Point(225,525)
52 | $button.Size = New-Object System.Drawing.Size(150,30) # Increased size
53 | $button.Text = 'Generate CSR'
54 | $button.Font = New-Object System.Drawing.Font("Arial", 12) # Increased font size for button
55 |
56 | # Add click event for CSR generation
57 | $button.Add_Click({
58 | if ($password1.Text -ne $password2.Text) {
59 | [System.Windows.Forms.MessageBox]::Show('Passwords do not match', 'Error', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
60 | return
61 | }
62 |
63 | $subjectParts = @()
64 | if ($commonName.Text) { $subjectParts += "CN=$($commonName.Text)" }
65 | if ($organization.Text) { $subjectParts += "O=$($organization.Text)" }
66 | if ($organizationalUnit.Text) { $subjectParts += "OU=$($organizationalUnit.Text)" }
67 | if ($country.Text) { $subjectParts += "C=$($country.Text)" }
68 | if ($state.Text) { $subjectParts += "ST=$($state.Text)" }
69 | if ($locality.Text) { $subjectParts += "L=$($locality.Text)" }
70 |
71 | $subjectString = $subjectParts -join '/'
72 |
73 | # Constructing the OpenSSL command
74 | $cmd = "openssl req -new -newkey rsa:2048 -nodes -keyout mykey.key -out mycsr.csr " +
75 | "-passout pass:$($password1.Text) -subj '/$subjectString'"
76 | try {
77 | Invoke-Expression $cmd
78 | [System.Windows.Forms.MessageBox]::Show('CSR Generation Complete', 'Success', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Information)
79 | } catch {
80 | [System.Windows.Forms.MessageBox]::Show("An error occurred: $_", 'Error', [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Error)
81 | }
82 | })
83 |
84 | $form.Controls.Add($button)
85 |
86 | #Show the form
87 | $form.ShowDialog()
88 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # PowerCSR
2 | **A GUI form built in Powershell to efficiently generate a CSR and Private Key file using OpenSSL for quick and easy cert generation**
3 |
4 |
5 |
6 | Use this tool to quickly do CSR requests for SSL certificates using Powershell on Windows.
7 |
8 | # Prequisites
9 |
10 | 1. Make sure you first have OpenSSL installed and your environmental variables set so that you can get to open ssl from a terminal for this.
11 |
12 | 2. Open the .ps1 file in the directory that you want to generate the files.
13 |
14 | 
15 |
16 | 3. Go ahead and enter some details and a password if you want to with in built error checking to make sure that they match or leave empty for no password on the private key which can be useful for embedded devices such as firewalls.
17 |
18 | 
19 |
20 | 4. The CSR and Private Key will be generated and a success message if everything went well.
21 |
22 | 
23 |
24 | 5. You'll find your files in the directory that you have run this from.
25 |
26 | 
27 |
28 | 6. We can double check that this is the correct information by going to an online CSR Decoder like this and paste in the CSR file text to check
29 |
30 | https://www.sslshopper.com/csr-decoder.html
31 |
32 | 
33 |
34 | 7. By default the encryption is set to 2048 bits and allows you to generate again without having to retype into the command line OpenSSL.
35 |
36 | 8. Enjoy your freshly made CSR and Private Key without the frustration
37 |
38 | # Finally!
39 |
40 | Please go ahead and follow me for more and feel free to comment on if this works for you, if you've found a way to make this process better or if there is anything in here that needs to be amended to make it flow better. I'd love to hear from anyone that has given this a try
41 |
42 |
43 |
44 | Yours technically,
45 | ReproDev
46 |
47 | # Still To Do: Work on the design of the UI - Last Edit 23/01/2024
48 |
49 |
50 |
--------------------------------------------------------------------------------