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
How to do a Filesystem Resize (ext3/ext4) on Redhat running on VMware
Viewed 1186 times since Wed, Jul 25, 2018
How setting the TZ environment variable avoids thousands of system calls
Viewed 1118 times since Mon, May 21, 2018
Open SSL Creating Certificate Signing Request — CSR Generation
Viewed 558 times since Mon, Feb 18, 2019
Manage SSH Key File With Passphrase
Viewed 539 times since Tue, Mar 5, 2019
LVM: Extend SWAP size by growing existing Logical Volume
Viewed 676 times since Sat, Jun 2, 2018
LVM: Create a new Logical Volume / Filesystem
Viewed 697 times since Sat, Jun 2, 2018
20 IPtables Examples For New SysAdmins
Viewed 332 times since Fri, May 15, 2020
Viewed 1763 times since Sat, Jun 2, 2018
high swap space utilization in LINUX
Viewed 485 times since Fri, Jul 13, 2018
RHEL: udev rules basics
Viewed 1033 times since Sat, Jun 2, 2018