-addext "subjectAltName = DNS:domain-name.com"
(available from OpenSSL 1.1.1. More on this can be found on this StackExchange thread)
As a workaround, the behavior in which the CommonName field is being treated can be temporarily re-enabled by adding the value x509ignoreCN=0 to the GODEBUG environment variable. For instance, by running the following command in the terminal:
echo 'GODEBUG=x509ignoreCN=0' > ~/.profile
The certificate file can be then inspected to confirm that it contains the Subject Alternative Name:
openssl x509 -in server.crt -noout -text
Which output should include an entry similar to this:
X509v3 Subject Alternative Name: DNS:myserver.com
NOTE: Xray versions greater than 3.37 are bundled with an updated version of Go. Starting from Go version 1.18, the GODEBUG=x509ignoreCN=0 flag is deprecated, therefore, the certificates should be updated to overcome the error as the workaround will no longer be valid.