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

JWK to RSAPublicKey ignore additional parameters #86

Closed
dj-neza opened this issue Jul 3, 2018 · 6 comments
Closed

JWK to RSAPublicKey ignore additional parameters #86

dj-neza opened this issue Jul 3, 2018 · 6 comments
Labels
bug Something is not working right help wanted We'd love for someone from the community to help out here

Comments

@dj-neza
Copy link

dj-neza commented Jul 3, 2018

I get JWK from Auth0 JWKSet and transform it to Data object, but when I try to get RSAPublicKey with the data, it throws the following error:

Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.typeMismatch(Swift.String, Swift.DecodingError.Context(codingPath: [JWKParameter(stringValue: "x5c", intValue: nil)], debugDescription: "Expected to decode String but found an array instead.", underlyingError: nil))

The problem appears to be "x5c" parameter which has its value in brackets ("x5c": [...]). Since I am getting keys directly from endpoint, the only way to solve this seems to be manually removing the brackets, but since I don't really need "x5c" parameter right now it makes me wonder if there is a way to ignore some parameters?

@ghost ghost added bug Something is not working right help wanted We'd love for someone from the community to help out here JWS labels Jul 3, 2018
@dj-neza
Copy link
Author

dj-neza commented Jul 3, 2018

After further research, this seems to be a bug so you might consider updating the library for this. This is how JWT Handbook describes the "x5c" parameter: "a Base64-URL encoded X.509 DER certificate or certificate chain. A certificate chain is represented as an ARRAY of such certificates...".

@ghost
Copy link

ghost commented Jul 8, 2018

Hi @dj-neza,

thanks for trying out JOSESwift.

Yes, you're right that looks like a bug. 🐞
JWK parameters are currently expected to be of type String which is wrong as you pointed out. 👍

We'll try to get that fixed soon. Thanks for reaching out!

@xavierLowmiller
Copy link
Contributor

Are there any known workarounds for this? I'm having this issue, too...

@ghost
Copy link

ghost commented Oct 2, 2018

Hi @xaverlohmueller, 👋

A workaround would be to not throw an error here or to try to decode an array of String if decoding String alone does not work.

Unfortunately, we're quite low on resources until the end of October. I'll do my best to provide at least a workaround for this issue in November. Sorry, for that delay. If anyone has time earlier, I'd also be happy to review and merge a pull request addressing this issue.

@xavierLowmiller
Copy link
Contributor

Thanks for your response!

I might find some time to make a PR for this.

@ghost
Copy link

ghost commented Oct 18, 2018

Hey all 👋

with the help of @xaverlohmueller we just released 1.3.1 which includes a workaround for your issues: Ignoring all non-string JWK parameters.

If you use JOSESwift via CocoaPods, make sure to run pod repo update to get the newest version.

Keep an eye on #117 for a final solution to this problem. Any input there is highly appreciated.


Update: There seems to be an issue with CocoaPods right now that prevents the newest release from being pushed to the pod trunk. I'll keep you posted when the release is live. In the mean time you can use the master branch to get the workaround. The release went through, everything should work now. 👍

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working right help wanted We'd love for someone from the community to help out here
Projects
None yet
Development

No branches or pull requests

2 participants