Categories: TutorialsUbuntu

How to Generate CSR (Certificate Signing Request) in Linux?

To obtain an SSL certificate, CSR (Certificate Signing Request) must be generated. It is later provided to the CA (Certificate Authority) who is responsible to provide such SSL certificates. Such CSR must be generated on the server. CSR includes and stores information such as Country Name, Organization name, domain name, common name, email address, the public key, and so on.

There are two types of certificates which are Self Signed Certificate and Certificate Authority

Self Signed certificates are usually generated to run the website in the developing phase or test environment. It is simply generated by using OpenSSL or any other tool which is free to use.

Sponsored

In other cases, running the website or applications on a production environment, the certificate must be used and generated after verifying by the trusted CA.

To generate Certificate Signing Request(CSR) in Linux:

In Linux, first, we must have to install tools like OpenSSL to generate Certificate Signing Request (CSR). Let’s see the command to install OpenSSL on Ubuntu 20.04.

$ sudo apt install openssl

To verify if OpenSSL is installed or not, you can run the following command:

$ sudo openssl -a

To generate CSR and key in Linux

We can run the following command to generate a CSR and key which will be provided later to trusted CA.

$ sudo openssl req -new -newkey rsa:2048 -nodes -keyout test.com.key -out test.com.csr

Here,

new = new request

new-key rsa:2048 = create 2048-bit RSA key

nodes = It tells to not encrypt the key

keyout = It species filename to forward key on private key

Sponsored

Out = It specifies filename to write CSR to

After executing the above command, it will ask to provide the details such as Country Name, Organization name, domain name, common name, email address. Also, be sure your legally registered company name must be matched with the details you provide. It will be verified perfectly by the Certificate Authority before issuing the certificate.

Here is the output section after executing the above command, you need to put details on:

Now, you can list and view the contents of the file that you have created with the above commands:

$ ls

You can check and print the contents of the CSR with the following command:

$ cat test.com.csr

Now, you can use such a CSR file to apply for SSL certificates from a trusted CA.

Conclusion:

With the above steps, you must have learned the process of creating a CSR file which is very necessary before applying for an SSL certificate from a Certificate Authority(CA). Thank you!

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.

Ubuntu Server Admin

Recent Posts

How to Fix VMware’s “Could not open /dev/vmmon” Error on Ubuntu

You’ve recently installed VMware Workstation on your Ubuntu system and encountered the frustrating “Could not…

5 hours ago

How to Fix Ubuntu 404 Errors While Fetching Dependencies

Have you ever found yourself staring at a terminal full of 404 errors while trying…

5 hours ago

How to Fix ‘Please Install All Available Updates’ Error When Upgrading Ubuntu 18.04 to 20.04 LTS

One particularly frustrating error that many users face when trying to upgrade from Ubuntu 18.04 …

5 hours ago

How to fix “Release is not valid yet” Error in Docker Containers

In the world of containerization, time synchronization issues can create unexpected roadblocks when working with…

5 hours ago

How to fix “Externally Managed Environment” Pip Errors on Ubuntu

If you’ve recently upgraded to Ubuntu 23.04 or newer, you might have encountered a frustrating…

5 hours ago

Ubuntu now officially supports NVIDIA Jetson: powering the future of AI at the edge

Canonical announces the General Availability of Ubuntu for the NVIDIA® Jetson Orin™ for edge AI…

12 hours ago