I was delivering few demos for Azure Application Gateway client side, I got information, there will be very limited Internet and only specific things will work in the given environment. In one of the demo I wanted to created few Self Signed SSL Certificates for Azure Application Gateway. In the demonstration, instead showing some complex and boring command lines to create Self Signed Certificates, I created below PowerShell GUI One Click Key and Self Signed Certificate Generator, To look little cool in presentation. After launching certificate tool utility looks like below.
After configuring and defining settings such as location password for Certificate in the utility, Click Generate Cert button, which will generate all self signed certificate files as shows below with Self Signed RootCA. By clicking Create Zip button, it will compress and create a Zip file for entire files inside defined folder.
Next article: Terraform String Encoding and Decoding with PowerShell
Download this script Powershell_Self_Signed_Certificate.ps1 here or it is also available on github.com.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
# .NOTES # -------------------------------------------------------------------------------- # Generated on: 13-Sep-25 8:15 PM # Generated for: Azure Application Gateway Demos # PowerShell Version: V7 # -------------------------------------------------------------------------------- # .DESCRIPTION # vCloud-lab.com Self Signed Certificate Generator $assemblies = ('System.Windows.Forms', 'System.Data', 'System.Drawing', 'PresentationFramework') $assemblies | Foreach-Object {[void][reflection.assembly]::Load($_)} Add-Type -AssemblyName "System.Drawing", "System.Windows.Forms", "System.Data", "System.Design", "PresentationFramework" [System.Windows.Forms.Application]::EnableVisualStyles() $WinForm = New-Object 'System.Windows.Forms.Form' $buttonCreateZip = New-Object 'System.Windows.Forms.Button' $statusstrip1 = New-Object 'System.Windows.Forms.StatusStrip' $groupbox_EndEntity = New-Object 'System.Windows.Forms.GroupBox' $label_AddEndEntityYearsInfo = New-Object 'System.Windows.Forms.Label' $label_DNSName = New-Object 'System.Windows.Forms.Label' $datetimepicker_EndEntityYears = New-Object 'System.Windows.Forms.DateTimePicker' $label_EndEntityAddYears = New-Object 'System.Windows.Forms.Label' $textbox_EndEntityDNSName = New-Object 'System.Windows.Forms.TextBox' $label_EndEntity = New-Object 'System.Windows.Forms.Label' $combobox_EndKeyLength = New-Object 'System.Windows.Forms.ComboBox' $textbox_EndEntityCAName = New-Object 'System.Windows.Forms.TextBox' $labelKeyLength = New-Object 'System.Windows.Forms.Label' $groupbox_RootCA = New-Object 'System.Windows.Forms.GroupBox' $label_AddRootCAYearsInfo = New-Object 'System.Windows.Forms.Label' $datetimepicker_RootCAYears = New-Object 'System.Windows.Forms.DateTimePicker' $labelAddYears = New-Object 'System.Windows.Forms.Label' $combobox_RootKeyLength = New-Object 'System.Windows.Forms.ComboBox' $labelRootCAKeyLength = New-Object 'System.Windows.Forms.Label' $labelCNName = New-Object 'System.Windows.Forms.Label' $textbox_CAName = New-Object 'System.Windows.Forms.TextBox' $buttonGenerateCert = New-Object 'System.Windows.Forms.Button' $maskedtextbox_PfxPassword = New-Object 'System.Windows.Forms.MaskedTextBox' $labelCertPassword = New-Object 'System.Windows.Forms.Label' $buttonSelectFolder = New-Object 'System.Windows.Forms.Button' $textbox_SelectFolderPath = New-Object 'System.Windows.Forms.TextBox' $labelPath = New-Object 'System.Windows.Forms.Label' $folderbrowserdialog_GetFolderPath = New-Object 'System.Windows.Forms.FolderBrowserDialog' $toolstripstatuslabel1 = New-Object 'System.Windows.Forms.ToolStripStatusLabel' $toolstripprogressbar_Status = New-Object 'System.Windows.Forms.ToolStripProgressBar' $toolstripstatuslabel_Status = New-Object 'System.Windows.Forms.ToolStripStatusLabel' $InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState' $WinForm_Load={ $currentRootCADate = $datetimepicker_RootCAYears.Value $10YrsDate = $currentRootCADate.AddYears(10) $datetimepicker_RootCAYears.Value = $10YrsDate $datetimepicker_RootCAYears.MinDate = (Get-Date).DateTime $datetimepicker_RootCAYears.MaxDate = (Get-Date).AddYears(20).DateTime $currentEndEntityDate = $datetimepicker_EndEntityYears.Value $1YrsDate = $currentEndEntityDate.AddYears(1) $datetimepicker_EndEntityYears.Value = $1YrsDate $datetimepicker_EndEntityYears.MinDate = (Get-Date).DateTime $datetimepicker_EndEntityYears.MaxDate = (Get-Date).AddYears(3).DateTime } $buttonSelectFolder_Click={ $folderbrowserdialog_GetFolderPath.ShowDialog() $textbox_SelectFolderPath.Text = $folderbrowserdialog_GetFolderPath.SelectedPath $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 } $buttonGenerateCert_Click={ if (!(Test-Path $textbox_SelectFolderPath.Text)) { #New-Item -Path $textbox_SelectFolderPath.Text -ItemType Directory -Force | Out-Null New-Item -Path "$($textbox_SelectFolderPath.Text)\Old" -ItemType Directory -Force | Out-Null $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 } else { Get-ChildItem $textbox_SelectFolderPath.Text -Exclude Old | Foreach-Object {Move-Item -Path $_.FullName -Destination "$($textbox_SelectFolderPath.Text)\Old" -Force } } $OutDir = $textbox_SelectFolderPath.Text $pfxPassword = $maskedtextbox_PfxPassword.Text $maskedtextbox_PfxPassword.Text | Out-File -FilePath $OutDir\_Password.txt $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 # ------------------------- # 1) Create Root key + certifica te (self-signed) # ------------------------- $rootKey = [System.Security.Cryptography.RSA]::Create([int]$combobox_RootKeyLength.SelectedItem) $rootPrivateKey = $rootKey.ExportRSAPrivateKeyPem() Set-Content -Path "$OutDir\RootCA_Private.key" -Value $rootPrivateKey | Out-Null $rootPublicKey = $rootKey.ExportRSAPublicKeyPem() Set-Content -Path "$OutDir\RootCA_Public.key" -Value $rootPublicKey | Out-Null $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 $rootSubject = [System.Security.Cryptography.X509Certificates.X500DistinguishedName]::new("CN=$($textbox_CAName.Text)") $rootReq = [System.Security.Cryptography.X509Certificates.CertificateRequest]::new( $rootSubject, $rootKey, [System.Security.Cryptography.HashAlgorithmName]::SHA256, [System.Security.Cryptography.RSASignaturePadding]::Pkcs1 ) $rootReq.CertificateExtensions.Add( [System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension]::new($true, $true, 3, $true) ) $rootReq.CertificateExtensions.Add( [System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension]::new($rootReq.PublicKey, $false) ) $rootKeyUsage = ` [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::KeyCertSign -bor ` [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::CrlSign -bor ` [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::DigitalSignature -bor ` [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::KeyEncipherment $rootReq.CertificateExtensions.Add( [System.Security.Cryptography.X509Certificates.X509KeyUsageExtension]::new($rootKeyUsage, $true) ) $rootCAYears = $datetimepicker_RootCAYears.Value.Year - (Get-Date).Year $rootNotBefore = [System.DateTimeOffset]::Now $rootNotAfter = $rootNotBefore.AddYears([System.Math]::Abs($rootCAYears)) $rootCert = $rootReq.CreateSelfSigned($rootNotBefore, $rootNotAfter) [System.IO.File]::WriteAllBytes("$OutDir\RootCA.cer", $rootCert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert)) $rootPfxBytes = $rootCert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, $pfxPassword) [System.IO.File]::WriteAllBytes("$OutDir\RootCA.pfx", $rootPfxBytes) $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 # ------------------------- # 2) Create Child key + CSR-like request and sign it with Root CA # ------------------------- $childKey = [System.Security.Cryptography.RSA]::Create([int]$combobox_EndKeyLength.SelectedItem) $childPrivateKey = $childKey.ExportRSAPrivateKeyPem() Set-Content -Path "$OutDir\$($textbox_EndEntityCAName.Text)_Private.key" -Value $childPrivateKey | Out-Null $ChildPublicKey = $childKey.ExportRSAPublicKeyPem() Set-Content -Path "$OutDir\$($textbox_EndEntityCAName.Text)_Public.key" -Value $ChildPublicKey | Out-Null $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 $childSubject = [System.Security.Cryptography.X509Certificates.X500DistinguishedName]::new("CN=$($textbox_EndEntityCAName.Text)") $childReq = [System.Security.Cryptography.X509Certificates.CertificateRequest]::new( $childSubject, $childKey, [System.Security.Cryptography.HashAlgorithmName]::SHA256, [System.Security.Cryptography.RSASignaturePadding]::Pkcs1 ) $childReq.CertificateExtensions.Add( [System.Security.Cryptography.X509Certificates.X509BasicConstraintsExtension]::new($false, $false, 0, $false) ) $childReq.CertificateExtensions.Add( [System.Security.Cryptography.X509Certificates.X509KeyUsageExtension]::new( [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::DigitalSignature -bor ` [System.Security.Cryptography.X509Certificates.X509KeyUsageFlags]::KeyEncipherment, $true ) ) $childReq.CertificateExtensions.Add( [System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension]::new($childReq.PublicKey, $false) ) $san = [System.Security.Cryptography.X509Certificates.SubjectAlternativeNameBuilder]::new() $san.AddDnsName("$($textbox_EndEntityDNSName.Text)") $childReq.CertificateExtensions.Add($san.Build()) $endEntityYears = $datetimepicker_EndEntityYears.Value.Year - (Get-Date).Year $childNotBefore = [System.DateTimeOffset]::Now $childNotAfter = $childNotBefore.AddYears($endEntityYears) $serial = New-Object byte[] 20 [System.Security.Cryptography.RandomNumberGenerator]::Fill($serial) $childCertPublic = $childReq.Create($rootCert, $childNotBefore, $childNotAfter, $serial) $childCert = [System.Security.Cryptography.X509Certificates.RSACertificateExtensions]::CopyWithPrivateKey($childCertPublic, $childKey) $childPfxBytes = $childCert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pfx, $pfxPassword) [System.IO.File]::WriteAllBytes("$OutDir\$($textbox_EndEntityDNSName.Text).pfx", $childPfxBytes) [System.IO.File]::WriteAllBytes("$OutDir\$($textbox_EndEntityDNSName.Text).cer", $childCert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert)) $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 # ------------------------- # 3) Export Private / Public Keys to PEM files # - Try modern API ExportRSAPrivateKeyPem()/ExportRSAPublicKeyPem() # - Fallback to ExportRSAPrivateKey()/ExportRSAPublicKey() (DER bytes) and wrap base64 # ------------------------- function Write-DerAsPem { param ( [byte[]]$Der, [string]$Header, [string]$OutPath ) $b64 = [System.Convert]::ToBase64String($Der) $lines = ($b64 -split "(.{1,64})" -ne "") $pem = "-----BEGIN $Header-----`n" + ($lines -join "`n") + "`n-----END $Header-----`n" Set-Content -Path $OutPath -Value $pem -NoNewline } function Save-RsaPrivateKeyPem { param ([System.Security.Cryptography.RSA]$rsa, [string]$pathPkcs1, [string]$pathPkcs8) if ($rsa -and $rsa.GetType().GetMethod("ExportRSAPrivateKeyPem")) { $pkcs1Pem = $rsa.ExportRSAPrivateKeyPem() Set-Content -Path $pathPkcs1 -Value $pkcs1Pem -NoNewline if ($rsa.GetType().GetMethod("ExportPkcs8PrivateKeyPem")) { $pkcs8Pem = $rsa.ExportPkcs8PrivateKeyPem() Set-Content -Path $pathPkcs8 -Value $pkcs8Pem -NoNewline } } else { $der = $rsa.ExportRSAPrivateKey() Write-DerAsPem -Der $der -Header "RSA PRIVATE KEY" -OutPath $pathPkcs1 $derPk8 = $rsa.ExportPkcs8PrivateKey() Write-DerAsPem -Der $derPk8 -Header "PRIVATE KEY" -OutPath $pathPkcs8 } } function Save-RsaPublicKeyPem { param ([System.Security.Cryptography.RSA]$rsa, [string]$path) if ($rsa.GetType().GetMethod("ExportRSAPublicKeyPem")) { $pem = $rsa.ExportRSAPublicKeyPem() Set-Content -Path $path -Value $pem -NoNewline } else { $der = $rsa.ExportRSAPublicKey() Write-DerAsPem -Der $der -Header "RSA PUBLIC KEY" -OutPath $path } } Save-RsaPrivateKeyPem -rsa $rootKey -pathPkcs1 "$OutDir\RootCA_private_pkcs1.pem" -pathPkcs8 "$OutDir\RootCA_private_pkcs8.pem" Save-RsaPublicKeyPem -rsa $rootKey -path "$OutDir\RootCA_public_rsa.pem" $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 Save-RsaPrivateKeyPem -rsa $childKey -pathPkcs1 "$OutDir\$($textbox_EndEntityDNSName.Text)_rsa_private_pkcs1.pem" -pathPkcs8 "$OutDir\$($textbox_EndEntityDNSName.Text)_private_pkcs8.pem" Save-RsaPublicKeyPem -rsa $childKey -path "$OutDir\$($textbox_EndEntityDNSName.Text)_public_rsa.pem" $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 # ------------------------- # 4) Export Certificate (PEM) and create combined PEM files # ------------------------- function Write-CertAsPem { param ([System.Security.Cryptography.X509Certificates.X509Certificate2]$cert, [string]$outPath) $der = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert) Write-DerAsPem -Der $der -Header "CERTIFICATE" -OutPath $outPath } Write-CertAsPem -cert $rootCert -outPath "$OutDir\RootCA.pem" Write-CertAsPem -cert $childCert -outPath "$OutDir\$($textbox_EndEntityDNSName.Text).pem" $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 $childPrivPem = Get-Content -Raw "$OutDir\$($textbox_EndEntityDNSName.Text)_private_pkcs8.pem" $childCertPem = Get-Content -Raw "$OutDir\$($textbox_EndEntityDNSName.Text).pem" Set-Content -Path "$OutDir\$($textbox_EndEntityDNSName.Text)_combined.pem" -Value ($childPrivPem + "`n" + $childCertPem) -NoNewline $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 $childCertContent = Get-Content -Raw "$OutDir\$($textbox_EndEntityDNSName.Text).pem" $rootCertContent = Get-Content -Raw "$OutDir\RootCA.pem" Set-Content -Path "$OutDir\$($textbox_EndEntityDNSName.Text)_chain.pem" -Value ($childCertContent + "`n" + $rootCertContent) -NoNewline $toolstripprogressbar_Status.Value = 100 $toolstripstatuslabel_Status.Text = "Certificates Generated." } $datetimepicker_RootCAYears_ValueChanged={ $rootCAYears = $datetimepicker_RootCAYears.Value.Year - (Get-Date).Year $label_AddRootCAYearsInfo.Text = $rootCAYears } $datetimepicker_EndEntityYears_ValueChanged={ $endEntityYears = $datetimepicker_EndEntityYears.Value.Year - (Get-Date).Year $label_AddEndEntityYearsInfo.Text = $endEntityYears } $buttonCreateZip_Click={ # ------------------------- # 4) Create a Zip file # ------------------------- $OutDir = $textbox_SelectFolderPath.Text $zipPath = Join-Path $OutDir "$($textbox_EndEntityDNSName.Text).zip" if (Test-Path $zipPath) { Remove-Item -Path $zipPath -Force $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 } $filesToZip = Get-ChildItem -Path $OutDir -File | Where-Object { $_.Extension -ne ".zip" } if ($filesToZip.Count -gt 1) { $toolstripprogressbar_Status.Value = Get-Random -Minimum 0 -Maximum 100 Compress-Archive -Path $filesToZip.FullName -DestinationPath $zipPath -Force -CompressionLevel Optimal $toolstripstatuslabel_Status.Text = "File: $($textbox_EndEntityDNSName.Text).zip" $toolstripprogressbar_Status.Value = 100 } else { $toolstripstatuslabel_Status.Text = "No files to zip." } } $Form_StateCorrection_Load= { $WinForm.WindowState = $InitialFormWindowState } $Form_StoreValues_Closing= { $script:MainForm_datetimepicker_EndEntityYears = $datetimepicker_EndEntityYears.Value $script:MainForm_textbox_EndEntityDNSName = $textbox_EndEntityDNSName.Text $script:MainForm_combobox_EndKeyLength = $combobox_EndKeyLength.Text $script:MainForm_combobox_EndKeyLength_SelectedItem = $combobox_EndKeyLength.SelectedItem $script:MainForm_textbox_EndEntityCAName = $textbox_EndEntityCAName.Text $script:MainForm_datetimepicker_RootCAYears = $datetimepicker_RootCAYears.Value $script:MainForm_combobox_RootKeyLength = $combobox_RootKeyLength.Text $script:MainForm_combobox_RootKeyLength_SelectedItem = $combobox_RootKeyLength.SelectedItem $script:MainForm_textbox_CAName = $textbox_CAName.Text $script:MainForm_textbox_SelectFolderPath = $textbox_SelectFolderPath.Text } $Form_Cleanup_FormClosed= { try { $buttonCreateZip.remove_Click($buttonCreateZip_Click) $datetimepicker_EndEntityYears.remove_ValueChanged($datetimepicker_EndEntityYears_ValueChanged) $datetimepicker_RootCAYears.remove_ValueChanged($datetimepicker_RootCAYears_ValueChanged) $buttonGenerateCert.remove_Click($buttonGenerateCert_Click) $buttonSelectFolder.remove_Click($buttonSelectFolder_Click) $WinForm.remove_Load($WinForm_Load) $WinForm.remove_Load($Form_StateCorrection_Load) $WinForm.remove_Closing($Form_StoreValues_Closing) $WinForm.remove_FormClosed($Form_Cleanup_FormClosed) } catch { Out-Null } $WinForm.Dispose() $labelPath.Dispose() $textbox_SelectFolderPath.Dispose() $folderbrowserdialog_GetFolderPath.Dispose() $buttonSelectFolder.Dispose() $labelCertPassword.Dispose() $maskedtextbox_PfxPassword.Dispose() $buttonGenerateCert.Dispose() $groupbox_RootCA.Dispose() $textbox_CAName.Dispose() $labelCNName.Dispose() $labelRootCAKeyLength.Dispose() $combobox_RootKeyLength.Dispose() $labelAddYears.Dispose() $datetimepicker_RootCAYears.Dispose() $label_AddRootCAYearsInfo.Dispose() $groupbox_EndEntity.Dispose() $labelKeyLength.Dispose() $combobox_EndKeyLength.Dispose() $label_EndEntity.Dispose() $textbox_EndEntityCAName.Dispose() $label_DNSName.Dispose() $textbox_EndEntityDNSName.Dispose() $label_AddEndEntityYearsInfo.Dispose() $datetimepicker_EndEntityYears.Dispose() $label_EndEntityAddYears.Dispose() $statusstrip1.Dispose() $toolstripstatuslabel1.Dispose() $toolstripprogressbar_Status.Dispose() $buttonCreateZip.Dispose() $toolstripstatuslabel_Status.Dispose() } $WinForm.SuspendLayout() $groupbox_RootCA.SuspendLayout() $groupbox_EndEntity.SuspendLayout() $statusstrip1.SuspendLayout() $WinForm.Controls.Add($buttonCreateZip) $WinForm.Controls.Add($statusstrip1) $WinForm.Controls.Add($groupbox_EndEntity) $WinForm.Controls.Add($groupbox_RootCA) $WinForm.Controls.Add($buttonGenerateCert) $WinForm.Controls.Add($maskedtextbox_PfxPassword) $WinForm.Controls.Add($labelCertPassword) $WinForm.Controls.Add($buttonSelectFolder) $WinForm.Controls.Add($textbox_SelectFolderPath) $WinForm.Controls.Add($labelPath) $WinForm.AutoScaleDimensions = New-Object System.Drawing.SizeF(8, 17) $WinForm.AutoScaleMode = 'Font' $WinForm.ClientSize = New-Object System.Drawing.Size(482, 453) $WinForm.FormBorderStyle = 'FixedDialog' $WinForm.Name = 'WinForm' $WinForm.Text = 'One Click Key & Self Signed Certificate' $WinForm.add_Load($WinForm_Load) $buttonCreateZip.Location = New-Object System.Drawing.Point(369, 394) $buttonCreateZip.Margin = '4, 4, 4, 4' $buttonCreateZip.Name = 'buttonCreateZip' $buttonCreateZip.Size = New-Object System.Drawing.Size(100, 30) $buttonCreateZip.TabIndex = 11 $buttonCreateZip.Text = 'Create Zip' $buttonCreateZip.UseVisualStyleBackColor = $True $buttonCreateZip.add_Click($buttonCreateZip_Click) [void]$statusstrip1.Items.Add($toolstripstatuslabel1) [void]$statusstrip1.Items.Add($toolstripprogressbar_Status) [void]$statusstrip1.Items.Add($toolstripstatuslabel_Status) $statusstrip1.Location = New-Object System.Drawing.Point(0, 428) $statusstrip1.Name = 'statusstrip1' $statusstrip1.Padding = '1, 0, 19, 0' $statusstrip1.Size = New-Object System.Drawing.Size(482, 25) $statusstrip1.TabIndex = 10 $statusstrip1.Text = 'statusstrip1' $groupbox_EndEntity.Controls.Add($label_AddEndEntityYearsInfo) $groupbox_EndEntity.Controls.Add($label_DNSName) $groupbox_EndEntity.Controls.Add($datetimepicker_EndEntityYears) $groupbox_EndEntity.Controls.Add($label_EndEntityAddYears) $groupbox_EndEntity.Controls.Add($textbox_EndEntityDNSName) $groupbox_EndEntity.Controls.Add($label_EndEntity) $groupbox_EndEntity.Controls.Add($combobox_EndKeyLength) $groupbox_EndEntity.Controls.Add($textbox_EndEntityCAName) $groupbox_EndEntity.Controls.Add($labelKeyLength) $groupbox_EndEntity.Location = New-Object System.Drawing.Point(13, 225) $groupbox_EndEntity.Margin = '4, 4, 4, 4' $groupbox_EndEntity.Name = 'groupbox_EndEntity' $groupbox_EndEntity.Padding = '4, 4, 4, 4' $groupbox_EndEntity.Size = New-Object System.Drawing.Size(454, 161) $groupbox_EndEntity.TabIndex = 9 $groupbox_EndEntity.TabStop = $False $groupbox_EndEntity.Text = 'Self Signed Certificate Information for End Entity' $label_AddEndEntityYearsInfo.AutoSize = $True $label_AddEndEntityYearsInfo.Location = New-Object System.Drawing.Point(395, 129) $label_AddEndEntityYearsInfo.Margin = '4, 0, 4, 0' $label_AddEndEntityYearsInfo.Name = 'label_AddEndEntityYearsInfo' $label_AddEndEntityYearsInfo.Size = New-Object System.Drawing.Size(16, 17) $label_AddEndEntityYearsInfo.TabIndex = 9 $label_AddEndEntityYearsInfo.Text = '1' $label_DNSName.AutoSize = $True $label_DNSName.Location = New-Object System.Drawing.Point(8, 96) $label_DNSName.Margin = '4, 0, 4, 0' $label_DNSName.Name = 'label_DNSName' $label_DNSName.Size = New-Object System.Drawing.Size(82, 17) $label_DNSName.TabIndex = 10 $label_DNSName.Text = 'DNS Name:' $datetimepicker_EndEntityYears.Location = New-Object System.Drawing.Point(122, 124) $datetimepicker_EndEntityYears.Margin = '4, 4, 4, 4' $datetimepicker_EndEntityYears.Name = 'datetimepicker_EndEntityYears' $datetimepicker_EndEntityYears.Size = New-Object System.Drawing.Size(265, 23) $datetimepicker_EndEntityYears.TabIndex = 8 $datetimepicker_EndEntityYears.add_ValueChanged($datetimepicker_EndEntityYears_ValueChanged) $label_EndEntityAddYears.AutoSize = $True $label_EndEntityAddYears.Location = New-Object System.Drawing.Point(8, 129) $label_EndEntityAddYears.Margin = '4, 0, 4, 0' $label_EndEntityAddYears.Name = 'label_EndEntityAddYears' $label_EndEntityAddYears.Size = New-Object System.Drawing.Size(78, 17) $label_EndEntityAddYears.TabIndex = 7 $label_EndEntityAddYears.Text = 'Add Years:' $textbox_EndEntityDNSName.Location = New-Object System.Drawing.Point(122, 93) $textbox_EndEntityDNSName.Margin = '4, 4, 4, 4' $textbox_EndEntityDNSName.Name = 'textbox_EndEntityDNSName' $textbox_EndEntityDNSName.Size = New-Object System.Drawing.Size(192, 23) $textbox_EndEntityDNSName.TabIndex = 9 $textbox_EndEntityDNSName.Text = 'Azure Application Gateway' $label_EndEntity.AutoSize = $True $label_EndEntity.Location = New-Object System.Drawing.Point(8, 65) $label_EndEntity.Margin = '4, 0, 4, 0' $label_EndEntity.Name = 'label_EndEntity' $label_EndEntity.Size = New-Object System.Drawing.Size(72, 17) $label_EndEntity.TabIndex = 8 $label_EndEntity.Text = 'CN Name:' $combobox_EndKeyLength.FormattingEnabled = $True [void]$combobox_EndKeyLength.Items.Add('1024') [void]$combobox_EndKeyLength.Items.Add('2048') [void]$combobox_EndKeyLength.Items.Add('3072') [void]$combobox_EndKeyLength.Items.Add('4096') $combobox_EndKeyLength.Location = New-Object System.Drawing.Point(122, 29) $combobox_EndKeyLength.Margin = '4, 4, 4, 4' $combobox_EndKeyLength.Name = 'combobox_EndKeyLength' $combobox_EndKeyLength.Size = New-Object System.Drawing.Size(192, 25) $combobox_EndKeyLength.TabIndex = 7 $combobox_EndKeyLength.Text = '2048' $textbox_EndEntityCAName.Location = New-Object System.Drawing.Point(122, 62) $textbox_EndEntityCAName.Margin = '4, 4, 4, 4' $textbox_EndEntityCAName.Name = 'textbox_EndEntityCAName' $textbox_EndEntityCAName.Size = New-Object System.Drawing.Size(192, 23) $textbox_EndEntityCAName.TabIndex = 7 $textbox_EndEntityCAName.Text = 'Azure Application Gateway' $labelKeyLength.AutoSize = $True $labelKeyLength.Location = New-Object System.Drawing.Point(8, 32) $labelKeyLength.Margin = '4, 0, 4, 0' $labelKeyLength.Name = 'labelKeyLength' $labelKeyLength.Size = New-Object System.Drawing.Size(84, 17) $labelKeyLength.TabIndex = 0 $labelKeyLength.Text = 'Key Length:' $groupbox_RootCA.Controls.Add($label_AddRootCAYearsInfo) $groupbox_RootCA.Controls.Add($datetimepicker_RootCAYears) $groupbox_RootCA.Controls.Add($labelAddYears) $groupbox_RootCA.Controls.Add($combobox_RootKeyLength) $groupbox_RootCA.Controls.Add($labelRootCAKeyLength) $groupbox_RootCA.Controls.Add($labelCNName) $groupbox_RootCA.Controls.Add($textbox_CAName) $groupbox_RootCA.Location = New-Object System.Drawing.Point(13, 89) $groupbox_RootCA.Margin = '4, 4, 4, 4' $groupbox_RootCA.Name = 'groupbox_RootCA' $groupbox_RootCA.Padding = '4, 4, 4, 4' $groupbox_RootCA.Size = New-Object System.Drawing.Size(454, 128) $groupbox_RootCA.TabIndex = 8 $groupbox_RootCA.TabStop = $False $groupbox_RootCA.Text = 'Self Signed Root CA Information' $label_AddRootCAYearsInfo.AutoSize = $True $label_AddRootCAYearsInfo.Location = New-Object System.Drawing.Point(395, 93) $label_AddRootCAYearsInfo.Margin = '4, 0, 4, 0' $label_AddRootCAYearsInfo.Name = 'label_AddRootCAYearsInfo' $label_AddRootCAYearsInfo.Size = New-Object System.Drawing.Size(24, 17) $label_AddRootCAYearsInfo.TabIndex = 6 $label_AddRootCAYearsInfo.Text = '10' $datetimepicker_RootCAYears.Location = New-Object System.Drawing.Point(122, 88) $datetimepicker_RootCAYears.Margin = '4, 4, 4, 4' $datetimepicker_RootCAYears.Name = 'datetimepicker_RootCAYears' $datetimepicker_RootCAYears.Size = New-Object System.Drawing.Size(265, 23) $datetimepicker_RootCAYears.TabIndex = 5 $datetimepicker_RootCAYears.add_ValueChanged($datetimepicker_RootCAYears_ValueChanged) $labelAddYears.AutoSize = $True $labelAddYears.Location = New-Object System.Drawing.Point(8, 93) $labelAddYears.Margin = '4, 0, 4, 0' $labelAddYears.Name = 'labelAddYears' $labelAddYears.Size = New-Object System.Drawing.Size(78, 17) $labelAddYears.TabIndex = 4 $labelAddYears.Text = 'Add Years:' $combobox_RootKeyLength.FormattingEnabled = $True [void]$combobox_RootKeyLength.Items.Add('1024') [void]$combobox_RootKeyLength.Items.Add('2048') [void]$combobox_RootKeyLength.Items.Add('3072') [void]$combobox_RootKeyLength.Items.Add('4096') $combobox_RootKeyLength.Location = New-Object System.Drawing.Point(122, 24) $combobox_RootKeyLength.Margin = '4, 4, 4, 4' $combobox_RootKeyLength.Name = 'combobox_RootKeyLength' $combobox_RootKeyLength.Size = New-Object System.Drawing.Size(192, 25) $combobox_RootKeyLength.TabIndex = 3 $combobox_RootKeyLength.Text = '4096' $labelRootCAKeyLength.AutoSize = $True $labelRootCAKeyLength.Location = New-Object System.Drawing.Point(8, 27) $labelRootCAKeyLength.Margin = '4, 0, 4, 0' $labelRootCAKeyLength.Name = 'labelRootCAKeyLength' $labelRootCAKeyLength.Size = New-Object System.Drawing.Size(79, 17) $labelRootCAKeyLength.TabIndex = 2 $labelRootCAKeyLength.Text = 'Key length:' $labelCNName.AutoSize = $True $labelCNName.Location = New-Object System.Drawing.Point(8, 60) $labelCNName.Margin = '4, 0, 4, 0' $labelCNName.Name = 'labelCNName' $labelCNName.Size = New-Object System.Drawing.Size(72, 17) $labelCNName.TabIndex = 1 $labelCNName.Text = 'CN Name:' $textbox_CAName.Location = New-Object System.Drawing.Point(122, 57) $textbox_CAName.Margin = '4, 4, 4, 4' $textbox_CAName.Name = 'textbox_CAName' $textbox_CAName.Size = New-Object System.Drawing.Size(192, 23) $textbox_CAName.TabIndex = 0 $textbox_CAName.Text = 'RootCA' $buttonGenerateCert.Location = New-Object System.Drawing.Point(335, 51) $buttonGenerateCert.Margin = '4, 4, 4, 4' $buttonGenerateCert.Name = 'buttonGenerateCert' $buttonGenerateCert.Size = New-Object System.Drawing.Size(132, 30) $buttonGenerateCert.TabIndex = 7 $buttonGenerateCert.Text = 'Generate Cert' $buttonGenerateCert.UseVisualStyleBackColor = $True $buttonGenerateCert.add_Click($buttonGenerateCert_Click) $maskedtextbox_PfxPassword.Location = New-Object System.Drawing.Point(124, 55) $maskedtextbox_PfxPassword.Margin = '4, 4, 4, 4' $maskedtextbox_PfxPassword.Name = 'maskedtextbox_PfxPassword' $maskedtextbox_PfxPassword.PasswordChar = '*' $maskedtextbox_PfxPassword.Size = New-Object System.Drawing.Size(203, 23) $maskedtextbox_PfxPassword.TabIndex = 6 $maskedtextbox_PfxPassword.Text = 'Computer@123' $labelCertPassword.AutoSize = $True $labelCertPassword.Location = New-Object System.Drawing.Point(13, 58) $labelCertPassword.Margin = '4, 0, 4, 0' $labelCertPassword.Name = 'labelCertPassword' $labelCertPassword.Size = New-Object System.Drawing.Size(103, 17) $labelCertPassword.TabIndex = 4 $labelCertPassword.Text = 'Cert Password:' $buttonSelectFolder.Location = New-Object System.Drawing.Point(335, 13) $buttonSelectFolder.Margin = '4, 4, 4, 4' $buttonSelectFolder.Name = 'buttonSelectFolder' $buttonSelectFolder.Size = New-Object System.Drawing.Size(134, 30) $buttonSelectFolder.TabIndex = 2 $buttonSelectFolder.Text = 'Select Folder' $buttonSelectFolder.UseVisualStyleBackColor = $True $buttonSelectFolder.add_Click($buttonSelectFolder_Click) $textbox_SelectFolderPath.Location = New-Object System.Drawing.Point(124, 17) $textbox_SelectFolderPath.Margin = '4, 4, 4, 4' $textbox_SelectFolderPath.Name = 'textbox_SelectFolderPath' $textbox_SelectFolderPath.Size = New-Object System.Drawing.Size(203, 23) $textbox_SelectFolderPath.TabIndex = 1 $textbox_SelectFolderPath.Text = 'C:\Temp\Certs' $labelPath.AutoSize = $True $labelPath.Location = New-Object System.Drawing.Point(13, 20) $labelPath.Margin = '4, 0, 4, 0' $labelPath.Name = 'labelPath' $labelPath.Size = New-Object System.Drawing.Size(41, 17) $labelPath.TabIndex = 0 $labelPath.Text = 'Path:' $folderbrowserdialog_GetFolderPath.Description = 'Launch Get Folder Path' $folderbrowserdialog_GetFolderPath.SelectedPath = 'C:\Temp\Certs' $toolstripstatuslabel1.Name = 'toolstripstatuslabel1' $toolstripstatuslabel1.Size = New-Object System.Drawing.Size(160, 20) $toolstripstatuslabel1.Text = ' Microsoft Azure Cloud ' $toolstripprogressbar_Status.Name = 'toolstripprogressbar_Status' $toolstripprogressbar_Status.Size = New-Object System.Drawing.Size(100, 19) $toolstripstatuslabel_Status.Name = 'toolstripstatuslabel_Status' $toolstripstatuslabel_Status.Size = New-Object System.Drawing.Size(49, 20) $toolstripstatuslabel_Status.Text = 'Status: vCloud-lab.com' $toolstripstatuslabel_Status.AutoSize = $false $toolstripstatuslabel_Status.Spring = $true $toolstripstatuslabel_Status.TextAlign = [System.Drawing.ContentAlignment]::MiddleLeft $toolstripstatuslabel_Status.Font = New-Object System.Drawing.Font("Segoe UI", 8, [System.Drawing.FontStyle]::Italic) $statusstrip1.ResumeLayout() $groupbox_EndEntity.ResumeLayout() $groupbox_RootCA.ResumeLayout() $WinForm.ResumeLayout() $InitialFormWindowState = $WinForm.WindowState $WinForm.add_Load($Form_StateCorrection_Load) $WinForm.add_FormClosed($Form_Cleanup_FormClosed) $WinForm.add_Closing($Form_StoreValues_Closing) $WinForm.ShowDialog() | Out-Null |
Useful Articles
Installing, importing and using any module in powershell
Microsoft PowerShell: Check Windows license activation status
Find next available free drive letter using PowerShell
Copy Files with PowerShell Remoting WINRM Protocol
Powershell Find application window state minimized or maximized
How to Install and Use Microsoft PowerShell on Linux
Configure PowerShell remoting between Windows and Linux
Get-PSRepository WARNING Unable to find module repositories
Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send
Creating an internal PowerShell module repository
How to sign PowerShell ps1 scripts
PowerShell Convert MAC address to Link-local address IPv6
PowerShell fix repair The trust relationship between this workstation and the primary domain failed
Resovled issue with PowerShell - Trust relationship Rejoin computers in domain without restart
PowerShell Invoke-WebRequest The request was aborted Could not create SSL TLS secure channel
PowerShell Invoke-WebRequest The underlying connection was closed: Could not establish trust relationship for the SSL TLS secure channel.


