Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Security and hardening

The certificate OpenSSL made has no Subject Alternative Name

ErrorNo X509v3 Subject Alternative Name line in the output of openssl x509 -text

Short answer

OpenSSL only writes the extensions you tell it to write. A certificate made with openssl req and only -subj has no subjectAltName, and browsers and TLS libraries match the host name against that field. Add it with -addext, or name an extensions section in a config file, then print the certificate to confirm.

  • Applies to OpenSSL 3.0, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the extensions of the certificate you made. If the output has no Subject Alternative Name block, the SAN was never written.

    openssl x509 -in server.crt -noout -ext subjectAltName
  2. 2Match what you see, then jump to its fix

    1. 1The -ext output is empty, and the certificate was made with openssl req -x509 and -subj only.The command line never asked for a SANFix
    2. 2You use -config with a file that sets x509_extensions (self-signed) or req_extensions (request) to a section that does not hold subjectAltName.The config file has no extensions section for the SANFix

What does the error look like?

  • No X509v3 Subject Alternative Name line in the output of openssl x509 -text
  • openssl x509 -ext subjectAltName prints nothing

Cause 1 of 2

The command line never asked for a SAN

1Check

Look at the command you ran. A CN in -subj sets the subject name only; it does not create a subjectAltName.

history | grep "openssl req"

2Fix

Add the name with -addext. The option can be repeated, and each value is a key=value pair.

openssl req -x509 -newkey rsa:2048 -noenc -days 365 \
  -keyout server.key -out server.crt \
  -subj "/CN=example.test" \
  -addext "subjectAltName = DNS:example.test,DNS:www.example.test,IP:127.0.0.1"

3Verify

Print the extension again: the DNS and IP names are listed.

openssl x509 -in server.crt -noout -ext subjectAltName

Confirmed by docs.openssl.org

Did this fix it?

Cause 2 of 2

The config file has no extensions section for the SAN

1Check

Find which section the config names for the command you run, and read that section.

grep -n -E "x509_extensions|req_extensions|subjectAltName" openssl.cnf

2Fix

Put the SAN into the section that the config names. x509_extensions applies with -x509, and req_extensions applies to a certificate request.

[ req ]
distinguished_name = dn
x509_extensions = v3_san
prompt = no

[ dn ]
CN = example.test

[ v3_san ]
subjectAltName = DNS:example.test,DNS:www.example.test

3Verify

Generate with -config and print the extension.

openssl req -x509 -newkey rsa:2048 -noenc -days 365 -config openssl.cnf -keyout server.key -out server.crt
openssl x509 -in server.crt -noout -ext subjectAltName

Confirmed by docs.openssl.org

Did this fix it?

How do I stop it coming back?

  • Keep one tested command or config file for test certificates in your repo and reuse it.
  • List every host name and IP you use, including 127.0.0.1, in the SAN when you make the certificate.
  • Print the SAN with openssl x509 -ext before you install any certificate.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.