Ana içeriğe geç

Generating SSL/TLS keys


  • A workstation and a server running Rocky Linux
  • OpenSSL installed on the machine that you are going to be generating the private key and CSR (Certificate Signing Request), and on the server where you will eventually be installing your key and certificates
  • Able to run commands comfortably from the command-line
  • Helpful: knowledge of SSL/TLS and OpenSSL commands


Nearly every web site today should be running with an SSL/TLS (secure socket layer) certificate. This procedure will guide you through generating the private key for your web site and then generating the CSR (certificate signing request) that you will use to purchase your certificate.

Generate the private key

For the uninitiated, SSL/TLS private keys can have different sizes, measured in bits, determining how hard they are to crack.

As of 2021, a website's recommended private key size is still 2048 bits. You can go higher, but doubling the key size from 2048 bits to 4096 bits is only about 16% more secure, takes more space to store the key, and causes higher CPU loads when processing the key.

This slows down your web site performance without gaining any significant security. Stick with the 2048 key size and always keep tabs on what is currently recommend To start with, ensure the installation of OpenSSL on your workstation and server:

dnf install openssl

If it is not installed, your system will install it and any needed dependencies.

The example domain is "" Remember that you will need to purchase and register your domain beforehand. You can purchase domains through several "Registrars".

If you are not running your own DNS (Domain Name System), you can often use the same providers for DNS hosting. DNS translates your named domain, to numbers (IP addresses, either IPv4 or IPv6) that the Internet can understand. These IP addresses will be where the web site is actually hosted.

Generate the key using openssl:

openssl genrsa -des3 -out 2048

Note that you named the key, with a .pass extension. That is because when you run this command, it requests that you enter a passphrase. Enter a simplistic passphrase that you can remember as you are going to be removing this shortly:

Enter pass phrase for
Verifying - Enter pass phrase for

Next, remove that passphrase. This is because if you do not remove it, you will need to enter that passphrase each time your website restarts and loads up your key.

You might not even be around to enter it, or worse, might not have a console available. Remove it now to avoid all of that:

openssl rsa -in -out

This will request that passphrase once again to remove the passphrase from the key:

Enter pass phrase for

Your password is now removed from the key now that you have entered the passphrase a third time, and saved as

Generate the CSR

Next, you need to generate the CSR (certificate signing request) that you will use to purchase your certificate.

Prompting for several pieces of information occurs during the generation of the CSR. These are the X.509 attributes of the certificate.

One of the prompts will be for "Common Name (e.g., YOUR domain name)". This field must have the fully qualified domain name of the server that the SSL/TLS is protecting. If the website to be protected will be, then enter at this prompt:

openssl req -new -key -out

This opens up a dialog:

Country Name (2 letter code) [XX]: enter the two character country code where your site resides, for example "US"

State or Province Name (full name) []: enter the full official name of your state or province, for example "Nebraska"

Locality Name (eg, city) [Default City]: enter the full city name, for example "Omaha"

Organization Name (eg, company) [Default Company Ltd]: If you want, you can enter an organization that this domain is a part of, or just hit ENTER to skip.

Organizational Unit Name (eg, section) []: This would describe the division of the organization that your domain falls under. Again, you can just hit ENTER to skip.

Common Name (eg, your name or your server's hostname) []: Here, you have to enter your site hostname, example ""

Email Address []: This field is optional, you can decide to fill it out or just hit ENTER to skip.

Next, the procedure prompts you to enter extra attributes. Skipping these is possible by hitting ENTER:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

Generating of your CSR is complete.

Purchasing the certificate

Each certificate vendor will have basically the same procedure. You purchase the SSL/TLS and term (1 or 2 years, etc.) and then you submit your CSR. To do this, you will need to use the more command, and then copy the contents of your CSR file.


Which will show you something like this:


You want to copy everything including the "BEGIN CERTIFICATE REQUEST" and "END CERTIFICATE REQUEST" lines. Then paste these into the CSR field on the web site where you are purchasing the certificate.

Before issuing your certificate, You may have to perform other verification steps depending on domain ownership, the registrar you are using, etc. When issued, it will include an intermediate certificate from the provider, which you will also use in the configuration.


Generating all of the bits and pieces for purchasing a web site certificate is not difficult using this procedure.

Author: Steven Spencer

Contributors: Ezequiel Bruni, Ganna Zhyrnova