-
-
Save nordineb/2e5af102c3e83de5e1ecdb361048fbcb to your computer and use it in GitHub Desktop.
Create a Self-Signed Cert 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 the cert | |
New-SelfSignedCertificate -DnsName 'foo.azurewebsites.net' -CertStoreLocation cert:\CurrentUser\My -KeyAlgorithm RSA -KeyLength 2048 -KeyExportPolicy Exportable #-KeyUsage DigitalSignature,nonRepudiation,keyEncipherment | |
#Look for the cert | |
dir Cert:\CurrentUser\My | |
#Export the cert to a PFX file | |
$mypwd = ConvertTo-SecureString -String "WhoFedTheDogCorn?" -Force –AsPlainText | |
dir Cert:\CurrentUser\My | Where Subject -EQ 'CN=foo.azurewebsites.net' | Export-PfxCertificate -ChainOption BuildChain -Password $mypwd -FilePath E:\Scratch\fooCert.pfx | |
#Clean-up: Remove the cert from the certificate store | |
dir Cert:\CurrentUser\My | Where Subject -EQ 'CN=microsoft-apiappf710aa4ba6b148fa8de060cd4ac32edf.azurewebsites.net' | Remove-Item | |
#Clean-up: Remove the PFX file | |
dir E:\Scratch\fooCert.pfx | Remove-Item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment