How To: Create Self-Signed Certificate – OpenSSL

What is a self-signed SSL certificate? A self-signed certificate is a certificate that is not signed by a trusted authority.

Nevertheless, the self-signed certificate provides the same level of encryption as a $100500 certificate signed by a trusted authority.

In this article i will show how to create a self-signed certificate that can be used for non-production or internal applications.

Cool Tip: Check the expiration date of the SSL Certificate from the Linux command line! The fastest way! Read more →

Create Self-Signed Certificate

Generate self-signed certificate using openssl:

$ openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes -days 365 -subj '/CN=localhost'

Options that you might want to change while creating a self-signed certificate:

OptionDescription
-newkey rsa:4096 Generate a 4096 bit RSA key.
-keyout key.pem Save a key to the key.pem file.
-out cert.pem Save a certificate to the cert.pem file.
-nodes Do not protect the private key with a passphrase.
-days 365 The number of days to make a certificate valid for.
-subj '/CN=localhost' Use this option to suppress questions about the contents of the certificate. Replace localhost with your desired domain name.
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
How To Run Multiple SSH Command On Remote Machine And Exit Safely
Viewed 4429 times since Tue, Aug 6, 2019
logrotate Understanding logrotate utility
Viewed 1880 times since Sun, Jan 12, 2020
Get UUID of Hard Disks [Update]
Viewed 2288 times since Tue, Jul 17, 2018
Netcat shell zabezpieczony hasłem
Viewed 2316 times since Thu, May 24, 2018
ubuntu How to reset lost root password on Ubuntu 16.04 Xenial Xerus Linux
Viewed 8341 times since Tue, Dec 8, 2020
Manage Linux Password Expiration and Aging Using chage
Viewed 4722 times since Tue, Sep 11, 2018
RHCS6: Basic operations on clustered services
Viewed 2757 times since Sun, Jun 3, 2018
Modifying the inode count for an ext2/ext3/ext4 file system
Viewed 15397 times since Fri, Sep 18, 2020
Linux - How to unlock and reset user’s account
Viewed 4661 times since Fri, Jun 8, 2018
Linux – Securing your important files with XFS extendend attributes
Viewed 7608 times since Wed, Jul 25, 2018