This is not a solution I recommend for a production server, but if you need a certificate for a development server, I have a solution for you.
I use use a PowerShell script to create a certificate, and then configure my IIS site to use the certificate.
Here is the script I use. Before running the script you must set the variable
$dnsname to the name of your site.
$dnsname = "aaa"
$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
After you run the script, you can assign the certificate to your site:
- Open IIS Manager
- Select your site
- Edit bindings for the site
- Add a new binding.
- For type, set
- For hostname, set the value of the
$dnsname variable from the PowerShell script.
- From the SSL certificate dropdown, select the certificate with the name that matches the hostname.
- Click OK to save your changes.
Now you can access your server using your preferred host name without getting any browser errors.
Note: Lest anyone mistake me for a PowerShell guru, I found this script on the internet long ago. I've been using it for years. At this point, I can't remember where I originally got, so unfortunately I cannot give proper credit.