How to create Self-Signed certificate by one line command with openssl
Behold
openssl req -newkey rsa:2048 -keyout domain.key -x509 -days 365 -out domain.crt -nodes
Output
Generating a RSA private key
...........................................................................+++++
...+++++
writing new private key to 'domain.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
Result
bob@computer> ls
domain.crt domain.key
bob@computer>openssl x509 -noout -text -in domain.crt
Certificate:
Data:
Version: 3 (0x2)
Serial Number:
21:24:52:fc:ef:dc:30:ed:3b:c3:8d:e9:be:b9:67:2f:24:81:51:49
Signature Algorithm: sha256WithRSAEncryption
Issuer: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
Validity
Not Before: Nov 10 09:36:59 2021 GMT
Not After : Nov 10 09:36:59 2022 GMT
Subject: C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public-Key: (2048 bit)
Kudos to baeldung Creating a Self-Signed Certificate With OpenSSL