Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Apache AH01909: server certificate does NOT include an ID which matches the server name

Technical article
Hosting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

When Apache starts or restarts, mod_ssl compares the certificate configured for each SSL virtual host with that host's ServerName. If no name in the certificate matches, it writes a warning such as AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name. Apache still starts. The warning is a pointer to a mismatch between the name Apache holds for the host and the names the certificate carries, and the text in front of the message tells you which name Apache used. Fix it by making the certificate list the host's name, or by setting ServerName to a name the certificate lists.

What the error means

The message is a warning, not an error. In the Apache httpd 2.4.62 source, the function ssl_check_public_cert in modules/ssl/ssl_engine_init.c calls modssl_X509_match_name with the virtual host's server_hostname. If that returns false, the code logs the warning with the message number 01909 and carries on.

The start of the log line is the virtual host's identifier plus the certificate's position. The identifier is built in ssl_util_vhostid in modules/ssl/ssl_util.c from the host's name and port, written name:port. The code then adds a colon and a counter that starts at 0 for the first SSLCertificateFile in the host. So www.example.com:443:0 reads as: the host named www.example.com, port 443, first certificate file. The SSLCertificateFile page says the directive "can be used multiple times (referencing different filenames)" for more than one algorithm, so :1 is the second.

The match, as the source reads (our own reading of the code): modssl_X509_match_name collects the dNSName entries of the certificate's subject alternative names and also its subject common names, and compares each with the server name, ignoring case. A wildcard entry counts only when it starts with *., and it matches only the single left-most label. So *.example.com matches www.example.com. It does not match example.com, and it does not match a.b.example.com.

Which name Apache holds depends on ServerName. Apache's page says that if a virtual host does not specify a ServerName, a server name will be inherited from the base server configuration, and if no server name was specified globally, one is detected at start-up through reverse DNS resolution of the first listening address. The same page says that if you omit ServerName from a name-based virtual host, "the server will default to a fully qualified domain name (FQDN) derived from the system hostname", and that this "can lead to counter-intuitive virtual host matching and is discouraged."

Likely causes

Cause What you see How to confirm
The certificate was issued without the host's name, for example for example.com only while the host is www.example.com The log line begins with the host's real name The certificate's name list lacks that name
ServerName is missing, so the host uses an inherited or derived name The log line begins with a name you did not intend, such as the global server name or the system hostname The virtual host has no ServerName line
ServerName is a different name from the one on the certificate Name before :443:0 differs from every name in the certificate Compare the two lists
The host points SSLCertificateFile at another site's certificate The certificate's names are valid, but for a different site The file named in SSLCertificateFile is not the file you expected
A wildcard certificate that does not reach the name Warning for the apex name or for a name two labels deep Wildcard is *.example.com and the host is example.com or a.b.example.com

Prove the cause before changing anything

All of these steps only read.

1. Find the lines. The ErrorLog directive names the log file; Apache's own example is /var/log/httpd/error_log. Use the file your configuration names. The GNU manual says "grep prints lines that contain a match for one or more patterns."

grep AH01909 /var/log/httpd/error_log

Note the text before the first colon pair, such as www.example.com:443:0. That is the name Apache compared.

2. List the virtual hosts as Apache parsed them. Apache's page describes the -S option as "Show the settings as parsed from the config file (currently only shows the virtualhost settings)." apachectl passes command line arguments through to httpd.

apachectl -S

A good result shows each *:443 host with the ServerName you intended. A bad result shows a name you did not write, such as the machine's own hostname.

3. Find the certificate file the host uses. Search the configuration for the directive; the path below is the one used in the example. The GNU manual says that with -r, "For each directory operand, read and process all files in that directory, recursively." and that -n will "Prefix each line of output with the 1-based line number within its input file."

grep -rn "SSLCertificateFile" /etc/httpd/conf.d

4. Read the names inside that certificate. OpenSSL's x509 manual page gives these two forms; the first prints the subject alternative names and the second the subject.

openssl x509 -in /etc/pki/tls/certs/www.example.com.crt -noout -ext subjectAltName
openssl x509 -in /etc/pki/tls/certs/www.example.com.crt -noout -subject

A good result is a list that contains the exact name from the log line, or a wildcard that covers it by the rule above. A bad result is a list without it.

Fix

The fix is one of two: make the certificate carry the name, or make ServerName say the name the certificate carries. Pick by the table above.

The certificate is missing the name

Run the two openssl x509 forms from step 4 on the new certificate file. A good result is a list that contains the exact name from the log line, or a wildcard that covers it by the rule above; if the new file does not list it, it is not the certificate to use. Once a file that lists the name is on the server, pointing the host at it is the SSLCertificateFile edit in the changing step below.

The host's name or its certificate file is wrong

First save the current state. The GNU manual says "cp copies files (or, optionally, directories)." Copy the virtual host's configuration file to a saved name beside it:

cp -p /etc/httpd/conf.d/example.com-ssl.conf /etc/httpd/conf.d/example.com-ssl.conf.2026-12-04

Risk: the next edit changes the name or the certificate of a live HTTPS site. A wrong file path or a syntax error can stop Apache from starting when it next restarts, which takes every site on this server offline. A different ServerName does not stop Apache, but it changes which requests this host answers, so check its ServerAlias lines too. Make the edit when traffic is low and do not restart until the syntax check passes.

Change whichever of the two lines is wrong, and leave the other as it is: ServerName has to be a name the certificate lists, and SSLCertificateFile has to point to the file that holds it. Apache's virtual host page advises that you "always explicitly list a ServerName in every name-based virtual host". The block shows both lines with the example's values:

ServerName www.example.com
SSLCertificateFile /etc/pki/tls/certs/www.example.com.crt

Check the syntax before anything is restarted. Apache's page says configtest "parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error".

apachectl configtest

Disruptive step: the next command gracefully restarts Apache. Apache's page says open connections are not aborted. A bad configuration can stop Apache from applying the change, and AH01909 is only written at start-up, so the restart is also what loads your edit.

apachectl graceful

Only if you need to back out: copy example.com-ssl.conf.2026-12-04 back over example.com-ssl.conf.

Risk: the back-out command overwrites the live virtual host file with the saved copy. It discards your change and any other edit made to that file since, so the warning returns.

cp -p /etc/httpd/conf.d/example.com-ssl.conf.2026-12-04 /etc/httpd/conf.d/example.com-ssl.conf

Check the restored file:

apachectl configtest

Disruptive step: the next command gracefully restarts Apache so that it loads the restored file. As above, open connections are not aborted.

apachectl graceful

Example (illustrative): on web01, the host www.example.com logs AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name. openssl x509 -noout -ext subjectAltName lists only DNS:example.com. The certificate was issued for the apex name. The administrator asks the issuer for a certificate that lists example.com and www.example.com, saves the host's configuration file, points SSLCertificateFile at the new file, runs apachectl configtest, and then the graceful restart.

Confirm the fix

  1. After the graceful restart, grep AH01909 the error log again. No new line for this host should carry a timestamp after the restart.
  2. Ask the server for its certificate by name. Apache's SSL how-to gives this form for s_client: openssl s_client -connect www.example.com:443 -status -servername www.example.com. Our own reading: the certificate it prints should be the new one.
  3. Repeat step 2 for each other name the certificate lists.

What to watch afterwards

  • Give every name-based virtual host its own ServerName. Apache says an inherited name "will influence name-based virtual host resolution".
  • When a certificate is renewed or replaced, read its names again with the two openssl x509 forms before the restart that loads it.
  • The browser side of a name mismatch, where one site is shown another site's certificate, is covered in Browser shows the wrong certificate for a site: SNI and the default virtual host.

Risks and limits

Sources