Skip to content

Instantly share code, notes, and snippets.

@xsolon
Created October 23, 2017 10:16
Show Gist options
  • Save xsolon/8a80c3b08760edca58d08847a41eff09 to your computer and use it in GitHub Desktop.
Save xsolon/8a80c3b08760edca58d08847a41eff09 to your computer and use it in GitHub Desktop.
Self Signed Certificate with PowerShell
# 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