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
Linux - How to get Memory information
Viewed 2582 times since Fri, Jun 8, 2018
Yum Update: DB_RUNRECOVERY Fatal error, run database recovery
Viewed 4924 times since Fri, Jan 17, 2020
Fałszujemy rozpoznania skanerów #2
Viewed 3614 times since Mon, May 21, 2018
How to find your System details using inxi
Viewed 4326 times since Sat, Jun 2, 2018
Linux Kernel /etc/sysctl.conf Security Hardening
Viewed 24540 times since Fri, Aug 3, 2018
Extending Linux LVM partitions script
Viewed 7156 times since Wed, Feb 6, 2019
LUKS List available methods of encryption for LUKS
Viewed 3680 times since Fri, Jul 13, 2018
RHEL7: How to get started with Firewalld.
Viewed 13192 times since Wed, May 22, 2019
How to configure an SSH proxy server with Squid
Viewed 4229 times since Sun, Dec 6, 2020
How To Ping Specific Port Number
Viewed 6061 times since Mon, Jun 1, 2020