I'm trying to generate a certificate with the following subjectAltName:
hostname
*.hostname
hostname.mydomain.local
*.hostname.mydomain.local
I generate the CSR via OpenSSL and then get the certificate from Microsoft Active Directory Certificate Services. Certificate works OK for the following alternative names:
hostname
hostname.mydomain.local
*.hostname.mydomain.local
But, *.hostname
just doesn't work. Testing with Curl, I get the following output:
% curl https://m.example/
curl: (51) SSL: certificate subject name '*.example' does not match target host name 'm.example'
If, on the other hand, I add 'm.example' as a subjectAltName, then it works. So, wildcard with shortened hostname just refuses to work.
Personal Experience
A while back I had a similar issue.
I had set up a local DNS for Windows and Linux servers with .staging as the TLD. To save on creating and signing certificates for each virtual host and avoid having to configure new IP addresses (non-SNI web servers), I created a key and cert for
*.staging
but all the clients I tried (including curl) only reported that certificate subject name*.staging
does not match target host name whenever I tried loading virtual hosts on our Staging server using TLS.Relevant RFCs
I spent ages trying to figure out why the wildcard certificate I had generated for
*.staging
wouldn’t work. I had read all the relevant RFCs but none of them specifically stated that such a wildcard certificate was invalid or illegal.Security Stack Exchange Answers
I was eventually enlightened after reading this excellent Security Stack Exchange answer.
...
The accepted answer to Can a wildcard SSL certificate be issued for a second level domain? also deserved an up-vote.
Edit
I figured that aside from recounting personal frustration, my answer doesn’t really add a lot other than linking to the RFCs and the relevant answers on Security Stack Exchange; I thought I’d put more effort in and search for the current relevant source code used by Chromium and Firefox.
Note that the comments in the Chromium source code explicitly mention that unknown top-level domains (such as
*.intranet
) are disallowed.Also: there’s no reference to a user-configurable option that can override this behaviour.
Mozilla source code
From mozilla-central Mercurial Repository
Chromium source code
From Chromium Git Repository
The comments in registry_controlled_domain.h are also relevant:
Both the Chromium and Mozilla projects base their definition of an effective TLD on the Public Suffix List as published by Mozilla.
HTTPS clients should refuse to match TLD wildcards like
*.com
or*.net
(or even*
) for security reasons: No single certificate should claim authority over a whole TLD.Now how is the client supposed to find out whether .example is a TLD (matching
*.example
forbidden) or a short form (matching allowed)? Particularly considering that new TLDs pop up every other day and any static TLD list would soon be outdated.So clients simply refuse to match any wildcard
*.XYZ
and expect to see at least two dots in a wildcard.Note that they should still maintain wildcard blacklists like
*.co.uk *.co.jp
etc.