kratos icon indicating copy to clipboard operation
kratos copied to clipboard

No private key?

Open leapit opened this issue 6 years ago • 4 comments

As document

https://github.com/ory/kratos/blob/2b3f29913be844498a02b9869789c2b2d4aaacf8/docs/docs/guides/zero-trust-iap-proxy-identity-access-proxy.mdx#id-token-mutator

The JWT is signed using a RS256 key. To verify the JWT we can use the public key provided by ORY Oathkeeper's JWKS API:

http://127.0.0.1:4456/.well-known/jwks.json

When verify JWT in header

Steps to reproduce the behavior:

  1. Use jwt way run this project
  2. Got jwt string eyJhbGciOiJSUzI1N.....
  3. Use jwks-rsa package,got public key from jwks.json
  4. Put jwt string and above public key in to jwt.io,got below
WechatIMG3

Only public key and no private key.Why not use private key as a pair to generate JWT,is this as expect by design?RSA should be appear always with public and private key.

Any misunderstanding?

leapit avatar Jul 05 '20 14:07 leapit

I think you’re confusing something. The set up is correct. The private key is not exposed, it would be a security issue. The public key is properly being used for verification.

aeneasr avatar Jul 05 '20 14:07 aeneasr

@aeneasr thanks,for more I want know, 1.the public key in jwks.json expose for all,every one can get jwt,and verify,the private key has nothing effect? 2.as RSA,should encrypt with private key and decrypt with private key too,but it seems no private key's work,why? 2.where is the private key,if a thirdpart app use this jwt,should use private key for decrypt?

leapit avatar Jul 06 '20 01:07 leapit

The private key is used to generate the signature, the public key is used to verify it. The private key is private (as the name says) and is not exposed. The private key is owned by ORY Oathkeeper in this example. We used a pre-generated key which you can find here.

NEVER EXPOSE THE PRIVATE KEY TO ANYONE. JUST KEEP IT PRIVATE.

Learn more about JWT and asymmetric cryptography here:

  • https://blog.miguelgrinberg.com/post/json-web-tokens-with-public-key-signatures
  • https://jwt.io/introduction/

aeneasr avatar Jul 06 '20 07:07 aeneasr

@aeneasr thanks for your kindness,just start a project,plan to use ory for passport etc.

leapit avatar Jul 06 '20 07:07 leapit