openssl req -x509 -sha256 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
Keep in mind: This is for local development. Put in additional safety for self-signed production certs.
Optional: Add the location and company information via parameter so you don’t have to manually enter it:
openssl req -x509 -sha256 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365 -subj "/C=US/ST=Oregon/L=Portland/O=Company Name/OU=Org/CN=www.example.com"