SSL | Generate self-signed certificate and key in one line

If you need a quick self-signed certificate, you can create a key/pair, sign it in just one line.

openssl req -subj '/O=Company Name/CN=domain.com/C=US' -new -newkey rsa:2048 -days 1095 -nodes -x509 -keyout server.key -out server.crt

Replace Company Name, Domain with your own.

I would also recommend calling the server keys something like domain.tld.key/crt

This certificate will expire after 3 years (1095 days)