Skip to content

Conversation

@styxit
Copy link
Contributor

@styxit styxit commented Apr 23, 2025

A wildcard certificate is not valid for the root domain.

The certificate *.example.com is NOT valid for the domain example.com

It would only be valid if contained an additional SAN to cover the root domain.

According to the this RFC, a wildcard certificate does not cover the root domain.
https://datatracker.ietf.org/doc/html/rfc6125#section-6.4.3

If the wildcard character is the only character of the left-most label in the presented identifier, the client SHOULD NOT compare against anything but the left-most label of the reference identifier (e.g., *.example.com would match foo.example.com but not bar.foo.example.com or example.com).

Where te last line describes the problem "*.example.com would match foo.example.com but not bar.foo.example.com or example.com"

The tests have been updated where the certificate that is being used contains a SAN for *.otherdomain.com. The subdomains www.otherdomain.com and another.otherdomain.com are valid, but the root domain otherdomain.com not.


@freekmurze
Copy link
Member

freekmurze commented Apr 24, 2025

Thanks!

@mattiasgeniar could you review this one?

@mattiasgeniar
Copy link
Contributor

Nice catch @styxit , you're right!

The test is also good, since the certificate loaded in the test covers "spatie.be" as well as "*.otherdomain.com" in the subjectAltName, it's correctly validating the fact that the root domain is not covered by that certificate.

Seems good to merge @freekmurze .

@freekmurze
Copy link
Member

Thanks!

@freekmurze freekmurze merged commit b51f1e4 into spatie:main Apr 25, 2025
12 checks passed
@styxit styxit deleted the wildcard-does-not-cover-root-domain branch April 29, 2025 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants