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
Top 20 OpenSSH Server Best Security Practices - good article
Viewed 11454 times since Mon, Oct 1, 2018
LVM: Mount LVM Partition(s) in Rescue Mode
Viewed 5637 times since Sat, Jun 2, 2018
LOGROTATE – ARCHIWIAZACJA LOGÓW
Viewed 2540 times since Fri, Nov 30, 2018
Use inotify-tools on CentOS 7 or RHEL 7 to watch files and directories for events
Viewed 14706 times since Fri, Jul 27, 2018
Tunnel SSH Connections Over SSL Using ‘Stunnel’ On Debian 7 / Ubuntu 13.10
Viewed 3973 times since Fri, Sep 28, 2018
Configuring VLAN interfaces in Linux
Viewed 6453 times since Mon, May 21, 2018
OpenSSL – sprawdzanie czy klucz pasuje do certyfikatu
Viewed 3157 times since Thu, May 24, 2018
How To Set Up an SSL Tunnel Using Stunnel on Ubuntu
Viewed 3825 times since Fri, Sep 28, 2018
Check a Website Availability from the Linux Command Line
Viewed 7248 times since Mon, Feb 18, 2019
Yum Update: DB_RUNRECOVERY Fatal error, run database recovery
Viewed 4665 times since Fri, Jan 17, 2020