The lab creates its certificate with openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout itia.key -out itia.crt. What do these options mean, and what kind of certificate is the result?
A self-signed certificate: -x509 outputs a certificate instead of a signing request, -newkey rsa:2048 makes a new 2048-bit RSA key, -nodes leaves the key unencrypted, and -days 365 makes it valid for a year.
| Option | Effect |
|---|---|
req |
the certificate-request tool |
-x509 |
output a self-signed certificate instead of a CSR (certificate signing request) |
-newkey rsa:2048 |
generate a new 2048-bit RSA key pair at the same time |
-nodes |
"no DES": don't encrypt the private key with a passphrase |
-days 365 |
validity period |
-keyout / -out |
where to write the key and the certificate |
openssl then asks for the distinguished name: country, organisation, and the important one, the Common Name, which should be the host name clients will use.
-nodes matters for automation: an encrypted key would make Apache ask for the passphrase at every start, which no unattended restart can answer. The trade-off is that the key file's permissions are its only protection (see the card on mode). Newer OpenSSL versions also accept -noenc for the same thing.
"Self-signed" means no certificate authority vouches for it: the certificate signs itself. The connection is encrypted, but a client has no way to tell this certificate from an attacker's, which is why browsers warn and why curl needs -k.
Go deeper:
openssl-req manual (OpenSSL docs) — every option of
openssl req.Self-signed certificate (Wikipedia) — what they are good for and what they can't prove.