Last active
July 7, 2016 09:52
-
-
Save ChrisTowles/9cf63fbba299f27d721c896adbc0dce5 to your computer and use it in GitHub Desktop.
For Local Development, to Create a Self Signed Cert and then add it to the Trusted Root Certifcations.
This file contains 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
#Note : NOT FOR PRODUCTION USE. Development boxes only. | |
Import-Module PKI | |
$tempPath = "C:\Temp" | |
$certPath = "$tempPath\SelfSignedCert.cer" | |
$dnsName = '*.somedomain.com' | |
#Create Temp Folder | |
New-Item -ItemType Directory -Force -Path $tempPath | |
#Create Certificate | |
$SelfSignedCert = New-SelfSignedCertificate -DnsName $dnsName -CertStoreLocation cert:\LocalMachine\My | |
write-host "Self Signed Cert for $dnsName Created." -ForegroundColor DarkYellow | |
#Export Cert to File | |
Export-Certificate -Cert $SelfSignedCert -FilePath $certPath -Type CERT | |
write-host "Self Signed Cert for $dnsName Exported." -ForegroundColor DarkYellow | |
#Import Cert as Trusted Root Cert | |
Import-Certificate -FilePath $certPath -CertStoreLocation cert:\LocalMachine\root | |
#Check if its Installed. | |
$certInstalled = Get-ChildItem -Path Cert:\LocalMachine\root | where {$_.Thumbprint -eq $SelfSignedCert.Thumbprint} | |
if($certInstalled -ne $null) | |
{ | |
write-host "Self Signed Cert for $dnsName Installed." -ForegroundColor DarkYellow | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment