OpenSSL: Find Out SSL Key Length – Linux Command Line

From the following article you’ll learn how to find out a key length of an SSL Certificate from the Linux command line, using OpenSSL utility.

The information about the key size can be retrieved from the several sources.

We can get the information about key length from the file with a private key, from the SSL certificate file or we can determine it directly from the https website.

Use the following OpenSSL commands from the Linux command line to get a key length:

Determine a Key Size from a Private Key

Linux command that retrieves a key size from a file with the private key (secret.key):

$ openssl rsa -in secret.key -text -noout | grep "Private-Key"
Private-Key: (2048 bit)

Find Out a Key Length from an SSL Certificate

Find out a key size from a file with the certificate (certificate.crt), using OpenSSL:

$ openssl x509 -in certificate.crt -text -noout | grep "Public-Key"
RSA Public-Key: (2048 bit)

Determine a Key Length from an HTTPS Site

Find out a key size from an https website, lets say google.com:

$ echo | openssl s_client -connect google.com:443 2>/dev/null | openssl x509 -text -noout | grep "Public-Key"
Public-Key: (2048 bit)
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments (1)
Comment By ONLINE PLACEMENT TRAINING - Wed, Dec 30th, 2020 12:30 PM
Hi, Thanks for sharing. Very informative post, that I have ever read, the strategy given is really very helpful....Here I’m giving best CRT ONLINE TRAINING details, once go through it. <a href="https://www.gobrainwiz.in/pages/crt">CRT training</a>
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
RHEL: ACLs basics
Viewed 7687 times since Sun, May 27, 2018
RHCS6: Create a new Logical Volume / Global Filesystem 2 (GFS2)
Viewed 3303 times since Sun, Jun 3, 2018
How to use yum command on CentOS/RHEL
Viewed 12425 times since Wed, Oct 17, 2018
Linux RAID Mdadm Cheat Sheet
Viewed 6613 times since Fri, May 15, 2020
20 Linux Command Tips and Tricks That Will Save You A Lot of Time linux
Viewed 5959 times since Thu, Apr 18, 2019
Check Detailed CPU Information In Linux With CoreFreq [Advanced]
Viewed 3495 times since Thu, Apr 18, 2019
Logowanie za pomocą kluczy Secure Shell
Viewed 3909 times since Thu, May 24, 2018
SSH Essentials: Working with SSH Servers, Clients, and Keys
Viewed 5805 times since Wed, Jun 27, 2018
Exclude multiple files and directories with rsync
Viewed 3354 times since Wed, Oct 31, 2018
RHCS6: Show/Add GFS2/GFS journals
Viewed 13522 times since Sun, Jun 3, 2018