Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using New-SelfSignedCertificate for wildcard certificates

Tags:

powershell

ssl

I have found this answer, but it doesn't seem to work when trying to create a wildcard certificate.

I have taken the following steps:

  1. Added a certificate to my server with the Powershell command.

New-SelfSignedCertificate -DnsName myhostname01,*.myhostname01 -CertStoreLocation Cert:\LocalMachine\My (I slightly censored the URL to avoid potentially unsafe situations).

  1. Next, I used the SSL certificate in a binding on my IIS server.

  2. I visited the page in Chrome. As expected, the certificate is marked unsafe.

enter image description here

  1. I saved a local copy of the certificate, and manually added a copy of of the certificate to my Chrome trusted CA's. However, the certificate is still not recognized:

    enter image description here

  2. The details of the certificate look like this:

enter image description here

Now, the certificates and URL I am visiting and have set up in my hosts file are all the same. There are no spelling errors. My question: am I using New-SelfSignedCertificate wrong? Or am I doing something wrong somewhere else?

like image 843
yesman Avatar asked Jun 09 '16 14:06

yesman


People also ask

Why you should not use wildcard certificate?

The biggest concern with wildcard certificates is that when one server or sub-domain covered by the wildcard is compromised, all sub-domains may be compromised. In other words, the upfront simplicity of the wildcard can create significant problems should things go wrong.

How do you make a wildcard self signed certificate in Windows?

If you want to test/laborate and need a wildcard certificate (SSL-certificate) you can create a selfsigned wildcard certificate in Windows. On the web-server (IIS): New-SelfSignedCertificate -CertStoreLocation "Cert:\LocalMachine\My" -DnsName "*.

Are wildcard certificates deprecated?

CN validation was deprecated for a long time and is finally being phased out; wildcard certificates are also deprecated (RFC 6125) and they too may eventually be phased out.


1 Answers

For anyone else who might arrive at this question clinging onto what's left of their sanity, the answer that ended up working for me was this:

New-SelfSignedCertificate -Subject *.my.domain -DnsName my.domain, *.my.domain -CertStoreLocation Cert:\LocalMachine\My -NotAfter (Get-Date).AddYears(10)

like image 168
Vinney Kelly Avatar answered Oct 02 '22 04:10

Vinney Kelly