How to Generate a Self-Signed Certificate with OpenSSL in Linux?

TLS (Transport Layer Security) is a secured protocol which is currently in trend. It can see used on top of the HTTP and application layer. The primary use of this protocol is to set up secure communication between web applications and servers. TLS protocol can also be used for secure email transfer, messaging and voice over IP.

Why SSL/TLS secure certificate?

Everyone wants a save website and secured payment gateways so that any kind of username, password and one-time password can not be used by a third party. SSL is a secure way of surfing the internet and it is used to protect our sensitive data. SSL/TLS is required to protect your websites.



Use of SSL/TLS secure certificate

We can use SSL/TLS secure certificate to establish an encrypted way of communication between you and the only recipient that you want to convey a message. We need a secure network packets so that it can not be accessed by third party. Here comes the role of the SSL/TLS secure certificate who can provide us the proper authentications while transferring network packets.

With the help of below command, we can generate our SSL certificate

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

This certificate is valid only for 365 days. Most of the parameters are fixed in this command like req, keyout and out. The private key name is up to your choice but it is required and the same for certificate as well. Below are the following steps that have to be followed to create this certificate.

Step 1: In this step, one should provide a password that is always required when you set up a connection with your server. One will not able to see the password while writing the password.

SSL Certificate Creation - 1

Step 2: In this step, one has to provide the country name with the starting two letters of your country.

SSL Certificate Creation - 2

Step 3: In this step one has to provide the full name of the state.

SSL Certificate Creation - 3



Step 4: In this step, one has to provide the organization name in which you are working or an organization for which this certificate is used for.

SSL Certificate Creation - 4

Step 5: In this step one has to provide the email address of your organization or if you are working as an individual one can give your email address.

SSL Certificate Creation - 5

After all the above steps are to be followed to make an SSL certificate and private key.

Private Key Generated:

Private Key

SSL Certificate Generated:

SSL Certificate

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.