2

I have private key (not RSA) and i want to generate JWT using <jwt.io> using RS256. How can I generate a token?

Whenever I enter my private key it says invalid signature. If I need to pass RSA private key then how to convert my private key to RSA private key? I am totally new to this.

jps
  • 20,041
  • 15
  • 75
  • 79
Hardin
  • 21
  • 2
  • My private goes like: "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADA.......Mh\n-----END PRIVATE KEY-----". – Hardin May 16 '21 at 13:15
  • If you don't have an RSA private key then you can't use RS256. There is no *sensible* way to convert a private key from a different public key cryptosystem into an RSA private key. The few characters of your PEM encoded private key that you have provided don't contain enough information to determine the type of private key. – President James K. Polk May 16 '21 at 13:59

1 Answers1

3

RS256 is an asymmetric signature algorithm, that means you need a keypair consisting of private and public key. You can generate such a pair with various online tools or with openssl. To generate (i.e sign) a token, you need the private key. But for verification, you need the public key. As long as you only paste the private key into the field in the right column, JWT.io can sign a token, but can't verify it. Therefore paste both keys of the pair into the key fields to get your token signed and verified.

jps
  • 20,041
  • 15
  • 75
  • 79