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
LVM: Move allocated PE between Physical Volumes
Viewed 1431 times since Sat, Jun 2, 2018
LVM: Remove an existing Volume Group
Viewed 981 times since Sat, Jun 2, 2018
stunnel How To Set Up an SSL Tunnel Using Stunnel on Ubuntu
Viewed 157 times since Sun, Dec 6, 2020
RHEL: Bonding network interfaces
Viewed 1435 times since Sat, Jun 2, 2018
high swap space utilization in LINUX
Viewed 868 times since Fri, Jul 13, 2018
RHEL: What is "SysRq key" and how to use it
Viewed 2061 times since Sat, Jun 2, 2018
Sample logrotate configuration and troubleshooting part 2
Viewed 868 times since Fri, Nov 30, 2018
10 Linux nslookup Command Examples for DNS Lookup
Viewed 768 times since Sun, Sep 30, 2018
RHEL: Enabling standard ftp/telnet
Viewed 1390 times since Sun, May 27, 2018
Linux - How to monitor memory usage
Viewed 855 times since Fri, Jun 8, 2018