Skip to content

Conversation

@m-barthelemy
Copy link

Noticed jwt-kit's X5CVerifier only 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?

@m-barthelemy m-barthelemy requested a review from ptoffy as a code owner December 7, 2025 06:51
Copy link
Member

@0xTim 0xTim left a 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

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))")
Copy link
Member

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

Copy link
Author

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!

}
}

@Test("Test signing with EdDSA x5c chain")
Copy link
Member

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

Copy link
Author

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.

@0xTim 0xTim added the semver-minor Contains new APIs label Dec 19, 2025
@m-barthelemy m-barthelemy requested a review from 0xTim December 19, 2025 21:36
Copy link
Member

@ptoffy ptoffy left a 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!

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

Labels

semver-minor Contains new APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants