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
stunnel basics and pki standards
Viewed 10309 times since Fri, Sep 28, 2018
How to enable Proxy Settings for Yum Command on RHEL / CentOS Servers
Viewed 14202 times since Thu, Jul 19, 2018
RHEL: Back-up/Replicate a partition table
Viewed 4354 times since Sun, May 27, 2018
HowTo: Kill TCP Connections in CLOSE_WAIT State
Viewed 17362 times since Thu, Feb 14, 2019
10 nmap Commands Every Sysadmin Should Know
Viewed 11033 times since Wed, May 22, 2019
List of 10 Must Know Oracle Database Parameters for Database Administrator
Viewed 146690 times since Thu, Jun 21, 2018
logrotate How log rotation works with logrotate
Viewed 9948 times since Sun, Jan 12, 2020
RHEL: GPT/MBR partition tables (using disks larger than 2 TiB)
Viewed 13337 times since Sun, May 27, 2018
RHEL: Extending a vmdk (Virtual Machine disk)
Viewed 5198 times since Sun, May 27, 2018
Increase A VMware Disk Size (VMDK) Formatted As Linux LVM without rebooting
Viewed 16763 times since Wed, May 30, 2018