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

$ echo | openssl s_client -connect 2>/dev/null | openssl x509 -text -noout | grep "Public-Key"
Public-Key: (2048 bit)
0 (0)
Article Rating (No Votes)
Rate this article
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="">CRT training</a>
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
15 Linux Yum Command Examples – Install, Uninstall, Update Packages
Viewed 1987 times since Thu, Oct 25, 2018
Enabling automatic updates in Centos 7 and RHEL 7
Viewed 1352 times since Wed, Oct 17, 2018
Script to Offline and Remove A Disk In Linux
Viewed 890 times since Mon, Jan 28, 2019
20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management YUM
Viewed 9948 times since Thu, Oct 25, 2018
logrotate How log rotation works with logrotate
Viewed 7802 times since Sun, Jan 12, 2020
Tcpdump Examples Linux
Viewed 4214 times since Fri, Nov 16, 2018
HowTo: Kill TCP Connections in CLOSE_WAIT State
Viewed 7655 times since Thu, Feb 14, 2019
Linux - How to get IP and MAC address of ethernet adapter in Linux
Viewed 1417 times since Fri, Jun 8, 2018
Tip: SSD and Linux. Enable TRIM and check if it works
Viewed 2423 times since Fri, May 15, 2020
Secure Secure Shell
Viewed 8431 times since Fri, Aug 21, 2020