Skip to content

Instantly share code, notes, and snippets.

@omkarkhair
Last active December 12, 2016 07:36
Show Gist options
  • Save omkarkhair/574e549a9ea9c3111ae4e83c100e2aba to your computer and use it in GitHub Desktop.
Save omkarkhair/574e549a9ea9c3111ae4e83c100e2aba to your computer and use it in GitHub Desktop.
Create a self-signed certificate using PowerShell 'New-SelfSignedCertificate'
$dns = "<ENTER_FULLY_QUALIFIED_DOMAIN>"
$pwd = "<ENTER_STRONG_PASSWORD>"
$exportPath = "<ENTER_PATH_TO_EXPORT_CERTIFICATES_TO>"
$certPath = "Cert:\LocalMachine\My\"
$cert = New-SelfSignedCertificate -CertStoreLocation $certPath -DnsName $dns
$certPath = "$($certPath)\$($cert.Thumbprint)"
Write-Host 'Cert path: ' $($certPath)
Export-Certificate -cert $certPath -FilePath $exportPath'\lab.cer'
$p = ConvertTo-SecureString -String $pwd -Force -AsPlainText
Export-PfxCertificate -cert $certPath -FilePath $exportPath'\lab.pfx' -Password $p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment