Interview Prep/Real-World Interview/DNS, TLS and certificates

`https://example.com` works, but `https://www.example.com` shows "NET::ERR_CERT_COMMON_NAME_INVALID".

BeginnerTroubleshootingDNS, TLS and certificates
Answer

Likely causes → The certificate's Subject Alternative Names cover example.com only. Browsers ignore the CN and check only SANs, so www doesn't match. A wildcard *.example.com also doesn't cover the bare apex.

Diagnose →

echo | openssl s_client -connect www.example.com:443 -servername www.example.com 2>/dev/null | openssl x509 -noout -ext subjectAltName

Fix → Reissue with both names, for example in cert-manager:

spec:
  dnsNames:
    - example.com
    - www.example.com

Then redirect www to the apex (or the other way round) so you have one canonical host.

Prevent → Keep the hostname list in one place (the Ingress or Certificate spec) and probe every public hostname, not just the main one.

All Real-World Interview questions Roadmap: Interview readiness

More on DNS, TLS and certificates