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.
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
RHEL: Displaying system info (firmware, serial numbers... )
Viewed 1235 times since Sun, May 27, 2018
RHCS6: Show/Add GFS2/GFS journals
Viewed 745 times since Sun, Jun 3, 2018
Need to set up yum repository for locally-mounted DVD on Red Hat Enterprise Linux 7
Viewed 761 times since Mon, Oct 29, 2018
Create a Linux Swap File
Viewed 580 times since Fri, Jun 8, 2018
LVM: Rename root VG/LV
Viewed 962 times since Sat, Jun 2, 2018
RHEL: Scan and configure new SAN (fibre channel) LUNs
Viewed 1099 times since Sun, May 27, 2018
RHCS6: Create a new Logical Volume / Global Filesystem 2 (GFS2)
Viewed 676 times since Sun, Jun 3, 2018
Get UUID of Hard Disks [Update]
Viewed 510 times since Tue, Jul 17, 2018
sed Delete / Remove ^M Carriage Return (Line Feed / CRLF) on Linux or Unix
Viewed 516 times since Thu, Feb 7, 2019
How to accurately determine when the system was booted
Viewed 469 times since Wed, Oct 3, 2018