Created
October 23, 2017 10:16
-
-
Save xsolon/8a80c3b08760edca58d08847a41eff09 to your computer and use it in GitHub Desktop.
Self Signed Certificate with PowerShell
This file contains hidden or 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
# Create certificate ------------------------------------------------------------- | |
$encrptCertFriendlyName = 'myCert' | |
$pfxPassWord = 'passwordCert' | |
$location = 'Cert:\LocalMachine\my'; | |
# This command needs to run on a modern powershell (win 10/server 2016, PSVersion >= 5.1) | |
$cert = New-SelfSignedCertificate -CertStoreLocation $location -Subject $encrptCertFriendlyName -KeySpec KeyExchange -NotAfter (Get-Date).AddYears(20) -FriendlyName $encrptCertFriendlyName -Type Custom | |
$mypwd = ConvertTo-SecureString -String $pfxPassWord -Force -AsPlainText | |
Export-pfxCertificate -FilePath 'c:\myCert.pfx' -Cert $cert -Password $mypwd | |
# -------------------------------------------------------------------------------- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment