Skip to content

Instantly share code, notes, and snippets.

@keyan1603
Created September 20, 2023 18:27
Show Gist options
  • Save keyan1603/b9b75d72e369b854492633180217678b to your computer and use it in GitHub Desktop.
Save keyan1603/b9b75d72e369b854492633180217678b to your computer and use it in GitHub Desktop.
Create SSL – Self signed certificate for your localhost website
$dnsname = "mysite.com"
$pwd = ConvertTo-SecureString -String "123456" -Force -AsPlainText
$print = (New-SelfSignedCertificate -certstorelocation cert:\localmachine\my -dnsname $dnsname).Thumbprint
$path = "c:\Windows\temp\cert.pfx"
Export-PfxCertificate -cert cert:\localMachine\my\$print -FilePath $path -Password $pwd
$file = ( Get-ChildItem -Path $path )
$file | Import-PfxCertificate -CertStoreLocation cert:\LocalMachine\Root -Password $pwd
Remove-Item $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment