Using New-SelfSignedCertificate for wildcard certificates Using New-SelfSignedCertificate for wildcard certificates powershell powershell

Using New-SelfSignedCertificate for wildcard certificates


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)


A SSL wild card certificate should have one subject with the wildcard and the rest of the DNS names should be in the Subject Alternative Name, which is provided by the DNSName parameter. I believe the example below will do what you want.

Example

New-SelfSignedCertificate -Subject *.myhostname01  -DnsName myhostname01 -CertStoreLocation Cert:\LocalMachine\My dir Cert:\LocalMachine\My\ | Where-Object {$_.Subject -eq 'CN=*.myhostname01'} | ForEach-Object {    [PSCustomObject] @{        Subject = $_.Subject        SAN = $_.DnsNameList    }}

Result

Subject           SAN-------           ---CN=*.myhostname01 {myhostname01}

References