-
-
Notifications
You must be signed in to change notification settings - Fork 61
X5CVerifier: support more signature algorithms #238
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
base: main
Are you sure you want to change the base?
Conversation
0xTim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this is the right approach, just some nits to add
Sources/JWTKit/X5C/X5CVerifier.swift
Outdated
| let eddsaKey = try EdDSA.PublicKey(pem: certificate.publicKey.serializeAsPEM().pemString) | ||
| return JWTSigner(algorithm: EdDSASigner(key: eddsaKey), parser: parser) | ||
| default: | ||
| throw JWTError.invalidX5CChain(reason: "Unsupported algorithm: \(String(describing: alg))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is the correct error - the chain could be valid but we don't support that algorithm so I think we should migrate it to something else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if the new error I added makes sense!
Tests/JWTKitTests/X5CTests.swift
Outdated
| } | ||
| } | ||
|
|
||
| @Test("Test signing with EdDSA x5c chain") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add tests for the other new algorithms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, however I'm not sure how you guys feel about me replacing the previously hardcoded key and certs with runtime-generated ones.
ptoffy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this and sorry for the wait!
This feature is long overdue. It looks like tests are failing because the other hardcoded certs are expired. I'll fix those up in a separate PR. In the meantime could you please switch the tests you added to be parameterised using swift-testing so we don't duplicate the same code over various tests? And could you also please run this through a swift-format round when done? Thanks!
Noticed jwt-kit's
X5CVerifieronly supports ES256 while trying to use Ed25519 certs and signatures.This PR tries to add support for ES384, ES512 and EdDSA (did not bother with RSA yet). Would that be an okay way of doing so?