Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: no implicit conversion of OpenSSL::PKey::RSA into String #259

Closed
yivo opened this issue Mar 23, 2018 · 6 comments
Closed

TypeError: no implicit conversion of OpenSSL::PKey::RSA into String #259

yivo opened this issue Mar 23, 2018 · 6 comments

Comments

@yivo
Copy link

yivo commented Mar 23, 2018

Steps to reproduce:

  1. JWT.encode({}, OpenSSL::PKey::RSA.generate(2048), 'HS384')
@excpt
Copy link
Member

excpt commented Mar 23, 2018

Thanks for reporting. What version of this gem are you using?

@ab320012
Copy link
Contributor

You are specifying a HMAC algo but then trying to sign it with a RSA key which is causing the issue

@yivo
Copy link
Author

yivo commented Mar 23, 2018

@excpt It is 2.1.0.

@ab320012 I thought it should work with RSA key. Isn't it?

@yivo
Copy link
Author

yivo commented Mar 23, 2018

It works if I provide RSA key as string in PEM format:

JWT.encode({}, OpenSSL::PKey::RSA.generate(2048).to_pem, 'HS384')

@ab320012
Copy link
Contributor

ab320012 commented Mar 23, 2018

@excpt will throwing JWT::EncodeError if hmac secret is not a String be okay in this case ?

@yivo the HMAC secret is a single key that encodes and decodes. RSA uses a public/ private key. the #to_pem call returns a string so it will work as a key for HMAC. In this case the HMAC key has to be a string like in the docs
@excpt chime in if i'm not getting something

@yivo
Copy link
Author

yivo commented Mar 23, 2018

@ab320012 OK, so in this case it is fine!

@excpt I think we can close the issue.

Thank you for the help!

@excpt excpt closed this as completed May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants