How to create self-signed certificate with SAN (subjectAltName) using OpenSSL

The following command will create a certificate with a subject alternative name (SAN) representing a self-signed wildcard certificate.

openssl req -x509 -sha512 -days 365000 -nodes -out cert.pem -newkey ed25519 -keyout privkey.pem -subj "/CN=mydomain.com" -addext "subjectAltName=DNS:*.mydomain.com"

Using this approach, no config file is required - all parameters can be passed using just the command line arguments.