The certificate OpenSSL made has no Subject Alternative Name
No X509v3 Subject Alternative Name line in the output of openssl x509 -textShort 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.
Fix it fast
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 subjectAltName2Match what you see, then jump to its fix
- 1
The -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
You 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
- 1
What does the error look like?
No X509v3 Subject Alternative Name line in the output of openssl x509 -textopenssl 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 subjectAltNameConfirmed by docs.openssl.org
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.cnf2Fix
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.test3Verify
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 subjectAltNameConfirmed by docs.openssl.org
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
Security
AuthenticationException: your certificate validation callback returned false
System.Security.Authentication.AuthenticationException
This message means a validation callback was installed, yours or one a library added, and it returned false.
3 causes, each with a fixSecurity
SSH to an EC2 instance fails with Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
ec2-user@ec2-203-0-113-25.compute-1.amazonaws.com: Permission denied (publickey).
On EC2 this error almost always means the instance did not accept your key for that user.
3 causes, each with a fixSecurity
gcloud init cannot finish the sign-in step
Enter authorization code
gcloud init signs in through a browser.
3 causes, each with a fixSecurity
A GitHub Actions SSH deploy step cannot log in to the server
ssh: handshake failed: ssh: unable to authenticate
The runner reached your server but the server refused the login.
4 causes, each with a fixSecurity
SSH to GitHub asks to confirm the host, or hangs on that prompt
ED25519 key fingerprint is SHA256:
SSH has never seen github.com from this machine, so it asks you to trust the server key.
2 causes, each with a fixSecurity
A GUI program over SSH says it cannot open the display
cannot open display:
ssh must forward X11 and the remote sshd must allow it.
3 causes, each with a fix