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

RS256, public and private keys #291

Closed
jbrayton opened this issue Dec 31, 2018 · 2 comments
Closed

RS256, public and private keys #291

jbrayton opened this issue Dec 31, 2018 · 2 comments

Comments

@jbrayton
Copy link

I notice that when generating a token using RS256 and a private key, I can verify that token with either the corresponding public key or the private key.

If I try to generate a token using RS256 and a public key, I get this error (which makes sense):

OpenSSL::PKey::ECError: Private EC key needed!

I want to be certain that either no one can possibly generate a token with RS256 and my public key, or that if they did it would fail verification. Is there a way someone could generate a token using RS256 with my public key? If they can, is there a way I can test that my code + JWT would refuse to verify it?

Thanks, and thank you for this very useful gem.

@excpt
Copy link
Member

excpt commented Jan 21, 2019

Hi @jbrayton,

there shouldn't be any way to recreate a private key from an existing public key. The key pair creation process is not part of the JWT specification.

By design of the private public key generation process it is only possible to create public keys from a private key. It is by design never be possible to create a private key from a public key.

The only thing you have to keep an eye on is the way you store the private key part. It should be kept secret for every 3rd party and should only be known to the token issuing instance.

@jbrayton
Copy link
Author

Thanks, @excpt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants