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

Importing JWK then exporting results in different kid #313

Closed
xcskier56 opened this issue May 21, 2019 · 1 comment
Closed

Importing JWK then exporting results in different kid #313

xcskier56 opened this issue May 21, 2019 · 1 comment

Comments

@xcskier56
Copy link

xcskier56 commented May 21, 2019

If you import a JWK from json and then export it back to JSON, it is exported with a changed kid. This means that the JWKs loader is failing to find the key by its id.

Gem Version: 2.2.0.pre.beta.0
Ruby Version: 2.6.3

    key_hash = {
      kty: "RSA",
      kid: "xQbOc1Ydqq3vemT9WN4GWuOZKOFSPXq1xzXxON_yWFg",
      e: "AQAB",
      n: "unkoQzE-VJwehDczS5o5ijyaAH2JyzhdLd7oSndnS63gzFRXS_LpDq62JLGHMFCYo11VYRb9kn2cdlfG0IANqTt9SWJ-iSKmdRnZIm-q5XCJGmW7C1Gazh9kgmMeWq3Zq5cv83r0e-KkcmWiT_XMrXutTTtUAVms1bCoGCEq7NBb5mnGeFxK51yxlNTnSMk0SJBuYvJ_13XISUQE-hwCdtd9LyDVFcggJcDejWlO3EIAtsWS4aPBt-ln9y9wIVpmsmjmsRTmXtS8B3KH6f6qAPuxzTmCNWLp_jh-W60o3lmgkMaqwdc0OjUpc6Lhn9E9LzqftXKpV3H6QRQgicQmyQ",
      use: "sig",
      alg: "RS256"
    }

    jwk = JWT::JWK.import(key_hash)

    export = jwk.export

    key_hash[:kid] == export[:kid] # FALSE

    key_hash[:kid] # => "xQbOc1Ydqq3vemT9WN4GWuOZKOFSPXq1xzXxON_yWFg"
    export[:kid] # => "68945d6bbec4cf6e228c3675671dbd39b5686425bb075285dd2d19593c48000a"
@anakinj
Copy link
Member

anakinj commented Dec 1, 2020

This is fixed in master: 83b6e61

@anakinj anakinj closed this as completed Oct 8, 2021
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

3 participants