OpenSSL "req -pubkey" - Extract Public Key from CSR

Q

How to extract the public key from a CSR using OpenSSL "req -pubkey" command?

✍: FYIcenter.com

A

If you want to extract the public key from a CSR (Certificate Signing Request), you can use the OpenSSL "req -pubkey" command as shown below:

C:\Users\fyicenter>\local\openssl\openssl.exe

OpenSSL> req -in my_rsa.csr -noout -pubkey -out test_pub.key

OpenSSL> pkey -pubin -in test_pub.key -text -noout
Public-Key: (1024 bit)
Modulus:
    00:d1:8b:18:1f:8d:8d:bf:cd:d2:75:f0:e9:f0:4a:
    25:73:98:12:82:87:91:98:cd:fb:d7:da:36:25:2c:
    2d:c3:1d:f1:ac:b6:76:cb:d1:fc:67:1f:18:b3:83:
    af:19:1b:8a:10:3d:f9:8a:25:01:85:da:16:d0:fa:
    f4:3e:cd:a6:1f:0b:7d:e6:29:91:85:fa:59:fe:36:
    5c:50:93:e0:fb:e3:6a:63:e4:66:1e:9c:83:e3:28:
    7b:21:57:73:f5:18:7b:9b:03:0f:67:5b:bd:56:01:
    dd:32:ca:32:fb:04:75:77:9d:66:de:c1:1f:80:01:
    c7:bc:57:a6:0b:b7:9e:26:57
Exponent: 65537 (0x10001)

Options used in this "req" command are:

  • "-in my_rsa.csr" - Read the CSR from the given file.
  • "-noout" - Do not include CSR itself in the output.
  • "-pubkey" - Extract the public key from the CSR
  • "-out test_pub.key" - Save output, the public key, to the given file.

 

OpenSSL "req -newkey" - Generate Private Key and CSR

OpenSSL "req -verify" - Verify Signature of CSR

OpenSSL "req" Command

⇑⇑ OpenSSL Tutorials

2016-11-20, 2066👍, 0💬