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

ECC Keys in JWKS Response cause Error #1

Closed
tscs37 opened this issue Dec 20, 2019 · 8 comments
Closed

ECC Keys in JWKS Response cause Error #1

tscs37 opened this issue Dec 20, 2019 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@tscs37
Copy link

tscs37 commented Dec 20, 2019

Currently if a JWKS Set contains both an RSA and a ECC key, jwks-client produces an error due to the missing e and n fields in the ECC key.

Using the #[serde(default)] tag in both fields solves the issue; as the library doesn't verify P256 keys, those will still fail but R256 keys continue to function, so it doesn't matter that the P256 key isn't a valid RSA key.

@jfbilodeau jfbilodeau self-assigned this Dec 20, 2019
@jfbilodeau
Copy link
Owner

Hey Tim,

Thanks for opening the issue. Is there any chance you could provide a sample keyset (json or url) to help me look at the issue?

@tscs37
Copy link
Author

tscs37 commented Dec 20, 2019

{
  "keys": Array[3][
    {
      "kid": "OuLjiRkq<<redacted>>",
      "kty": "RSA",
      "alg": "RS256",
      "use": "sig",
      "n": "<<redacted>>",
      "e": "AQAB",
      "x5c": Array[1][
        "<<redacted>>"
      ],
      "x5t": "<<redacted>>",
      "x5t#S256": "<<redacted>>"
    },
    {
      "kid": "bjFH5u9T<<redacted>>",
      "kty": "RSA",
      "alg": "RS256",
      "use": "sig",
      "n": "<<redacted>>",
      "e": "AQAB",
      "x5c": Array[1][
        "<<redacted>>"
      ],
      "x5t": "<<redacted>>",
      "x5t#S256": "<<redacted>>"
    },
    {
      "kid": "keZwNXPO<<redacted>>",
      "kty": "EC",
      "alg": "ES256",
      "use": "sig",
      "crv": "P-256",
      "x": "<<redacted>>",
      "y": "<<redacted>>"
    }
  ]
}

I do have to redact the actual key material for various reasons so sadly this won't enable you to test the verification itself. The JWKS Data is generated by Keycloak.

@jfbilodeau
Copy link
Owner

That's perfect Tim. Much appreciated.

jfbilodeau added a commit that referenced this issue Dec 20, 2019
jfbilodeau added a commit that referenced this issue Dec 20, 2019
jfbilodeau added a commit that referenced this issue Dec 20, 2019
@jfbilodeau
Copy link
Owner

Hey Tim, an updated version of jwks_client should be available in crate.io (0.1.8). If you could test and let me know if that fixes the error for you that would be greatly appreciated. Thanks again for your help.

@jfbilodeau jfbilodeau added the bug Something isn't working label Dec 20, 2019
@tscs37
Copy link
Author

tscs37 commented Dec 20, 2019

Thanks, I won't be able to test the code until early January since we are closed over christmas but I appreciate the quick fix!

@jfbilodeau
Copy link
Owner

Thank. I'm make the issue as closed, but feel free to re-open should there be a problem. Have a great holiday!

@tscs37
Copy link
Author

tscs37 commented Jan 8, 2020

Hi, just a closing remark; I was able to test the patch and it works like a charm! Thank you very much!

@jfbilodeau
Copy link
Owner

Thank you for helping me improve jwks-client!

JadedBlueEyes pushed a commit to JadedBlueEyes/jsonwebtoken that referenced this issue Apr 13, 2023
JadedBlueEyes pushed a commit to JadedBlueEyes/jsonwebtoken that referenced this issue Apr 13, 2023
JadedBlueEyes pushed a commit to JadedBlueEyes/jsonwebtoken that referenced this issue Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants