-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Guillermo Alías
committed
Jan 25, 2023
1 parent
df13c86
commit 1293f12
Showing
10 changed files
with
525 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Working example of Power shell code that is able to generate a self-signed certificate with exportable private key. | ||
|
||
$certFilePath = "C:\certs" | ||
$certStoreLocation = "Cert:\LocalMachine\My" | ||
$pwd = "dilandau2001" | ||
|
||
$cert = New-SelfSignedCertificate ` | ||
-KeyFriendlyName "dilan.ServiceDiscovery" ` | ||
-KeyDescription "Dilan Service discovery" ` | ||
-KeyAlgorithm "RSA" ` | ||
-DnsName "dilan.ServiceDiscovery" ` | ||
-NotBefore (Get-Date).AddYears(-1) ` | ||
-NotAfter (Get-Date).AddYears(50) ` | ||
-KeyUsage CertSign, CRLSign, DataEncipherment, DigitalSignature, NonRepudiation ` | ||
-KeyUsageProperty All ` | ||
-KeyLength 2048 ` | ||
-CertStoreLocation $certStoreLocation ` | ||
-KeyExportPolicy Exportable ` | ||
-KeyProtection None ` | ||
-Type Custom | ||
|
||
$certThumb = $cert.Thumbprint | ||
$certPath = "$certStoreLocation\$certThumb" | ||
$cert | Export-PfxCertificate -FilePath "$certFilePath\$certThumb.pfx" -Password (ConvertTo-SecureString -String $pwd -AsPlainText -Force) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.