Advanced command examples
The following commands are used by development to generate certificates for testing. These commands use the –newkey option to generate both the private key and the certificate with a single command. Refer to the OpenSSL command help for information on the other options used here.
Self-signed certificate with private key encrypted; must enter passphrase
- Windows
Openssl> req -x509 -sha256 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 1460
- Linux
$ openssl req -x509 -sha256 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 1460
Self-signed certificate with private key not encrypted
- Windows
Openssl> req -x509 -sha256 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650 –nodes
- Linux
$ openssl req -x509 -sha256 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650 –nodes