Forrest logo
back to the openssl tool

ssl:certificate:self-signed:create

Generate a self-signed SSL certificate
$ openssl req -x509 -newkey rsa:4096 -keyout ${key_file} -out ${cert_file} -sha256 -days ${expiration_days}
try on your machine

This command is used to generate a self-signed X.509 certificate using OpenSSL.

Here's a breakdown of the command and its options:

  • openssl req: Invokes the OpenSSL command-line tool for certificate requests and certificate generation.
  • -x509: Specifies that an X.509 certificate should be created instead of a certificate signing request (CSR).
  • -newkey rsa:4096: Generates a new RSA private key with a bit length of 4096.
  • -keyout ${key_file}: Specifies the output file for the generated private key. The ${key_file} is a placeholder that should be replaced with the actual filename and path.
  • -out ${cert_file}: Specifies the output file for the generated X.509 certificate. The ${cert_file} is a placeholder that should be replaced with the actual filename and path.
  • -sha256: Specifies the message digest algorithm (SHA-256) to be used for the certificate.
  • -days ${expiration_days}: Specifies the validity period (in days) for the generated certificate. The ${expiration_days} is a placeholder that should be replaced with the desired number of days.

By executing this command with the appropriate values provided for ${key_file}, ${cert_file}, and ${expiration_days}, you will generate a new RSA private key and a corresponding X.509 certificate with the specified configuration.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the openssl tool