-
Notifications
You must be signed in to change notification settings - Fork 186
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
b64 InvalidCastException #121
Comments
Sure can absolutely do it. Are you facing this issue in real world? Mind unit test or sample data? I also happy to accept PR :) |
Thanks for your response. Client Code Sample |
@fdres thanks for example. May i ask why you putting string value for b64 header instead of boolean? RFC7797 pretty clear defines (https://tools.ietf.org/html/rfc7797#section-3):
Obviously i don't mind to add fix to support string values as well if it helps in real world. Just trying to understand what is real use case for it? |
I started using the nuget in version 2.4.0. When I sent the b64 header as boolean I got an IntegrityException with the message "Invalid Signature". When I changed the value to a string it validated the payload. |
I see. Are you using https://kjur.github.io/jsrsasign/ ? Probably i need to craft some example. |
"Are you using https://kjur.github.io/jsrsasign/ ?" |
@fdres i'm not super sure but i can't find that
Pretty simple to verify, just generate 2 tokens via jsrsasign: one with b64=true, another with b64=false and post here or compare yourself. Pretty sure you'll get identical payload part within. |
@dvsekhvalnov |
Yeah, for sure i agree we should improve error handling, InvalidCastException is terrible ) I'm slightly disagree with accepting "string" values for b64 header as it against spec and no real use case. Will publish fix in next minor version. |
Hi.
Inside private static byte[] DecodeBytes(...) in JWT.cs there is this piece of code:
object value; if (headerData.TryGetValue("b64", out value)) { b64 = (bool) value; }
If value is "false" or "true" this will throw an InvalidCastException.
Would you consider the change to
b64 = Convert.ToBoolean(value);
The text was updated successfully, but these errors were encountered: