Self-signed/CSR certificate rejected: no Subject Alternative Name (openssl req needs -addext)

A certificate made with a plain openssl req has only a CN, and modern clients ignore the CN.

Exact message you may see openssl req subjectAltName -addextcertificate has no Subject Alternative Namex509: certificate relies on legacy Common Name fieldmissing subject alternative name self-signednet::ERR_CERT_COMMON_NAME_INVALID self signed no SAN
Seen on: OpenSSL SSL Chrome

Meaning

Add the SAN when creating it: openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 365 -subj "/CN=example.com" -addext "subjectAltName=DNS:example.com,DNS:www.example.com,IP:127.0.0.1". For CSRs, put SANs in an openssl.cnf section or -addext.

Common causes

  • CN-only certificate
  • No -addext subjectAltName
  • SANs missing in the config file
  • Using an old tutorial
  • IP access without an IP SAN

⚡ Quick fix

  1. Use -addext subjectAltName=...
  2. Define [alt_names] in a config and -extensions v3_req
  3. Re-issue the certificate

Detailed fix by platform

Shell

  1. openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 365 -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"

How to diagnose

  1. SAN — Present?
  2. CN — Only name?
  3. Command — Includes addext?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

apex — Wildcard certificate *.example.com doesn't cover example.com (the bare domain) (SSL / TLS)apexCSR — CA rejects the CSR: invalid subject (country code, empty fields, wrong CN/SAN) or key too small (SSL / TLS)CSRDEPTH_ZERO_SELF_SIGNED_CERT — Node/OpenSSL: Error: self signed certificate (code: DEPTH_ZERO_SELF_SIGNED_CERT) (SSL / TLS)DEPTH_ZERO_SELF_SIGNE…Django — Django send_mail: ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] (EMAIL_USE_SSL vs EMAIL_USE_TLS on the wrong port) (Email / SMTP)Djangoerror 62 — openssl verify error:num=62:Hostname mismatch / Verify return code: 62 (SSL / TLS)error 62legacy CN — Go: x509: certificate relies on legacy Common Name field, use SANs instead (SSL / TLS)legacy CNlocalhost HTTPS — HTTPS on localhost shows NET::ERR_CERT_AUTHORITY_INVALID — trust a local development certificate (mkcert) (SSL / TLS)localhost HTTPSNET::ERR_CERT_COMMON_NAME_INVALID — NET::ERR_CERT_COMMON_NAME_INVALID: Your connection is not private (certificate is for a different domain) (SSL / TLS)NET::ERR_CERT_COMMON_…SAN

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.