Subject Alternative Names and Wildcard Certificates
What you'll learn: How a single certificate can secure multiple domains and when wildcard certificates make sense (or become risky).
The Problem with Single-Name Certificates
Traditional X.509 certificates specify one domain in the Subject field's Common Name (CN). But what if your company runs example.com, www.example.com, and api.example.com? Do you need three separate certificates?
Subject Alternative Names (SANs)
The Subject Alternative Name (SAN) extension solves this problem. It's a certificate extension that lets you list multiple domain names, IP addresses, or even email addresses in a single certificate.
Example: One certificate can protect:
example.comwww.example.comshop.example.com192.0.2.10(IP address)
When a browser connects, it checks if the hostname matches any entry in the SAN list. Think of SANs like a guest list at an exclusive party—if your name appears anywhere on the list, you're allowed in.
Wildcard Certificates
A wildcard certificate uses an asterisk (*) in the domain name, like *.example.com. This matches any single-level subdomain:
- ✅
shop.example.com - ✅
api.example.com - ❌
sub.shop.example.com(two levels deep—doesn't match)
Security implications:
- Convenience vs. risk tradeoff: One compromised server with the wildcard certificate's private key now threatens all your subdomains.
- Broader attack surface: An attacker who steals the key can impersonate any subdomain covered by the wildcard.
- Best practice: Use wildcards sparingly. For high-security applications, prefer explicit SANs or individual certificates per service.
When to Use Each
- SANs: Known, finite list of domains (e.g., main site + API + CDN endpoint)
- Wildcards: Many dynamic subdomains (e.g., tenant-specific URLs like
customer1.saas.com,customer2.saas.com)
Key Takeaway: SANs enable multi-domain certificates for flexibility; wildcard certificates trade convenience for broader compromise risk—use them carefully and consider the blast radius if the key is stolen.