-
Hello, I'm issuing tokens from a java web app without encoding base 64 the key I am trying to validate the token on php like this:
but it says that "Token signature mismatch" Changing the way I generate the token on java to this: works like a charm. But the problem is that I cannot change the token generation in java. Any help here, please? How can I avoid the base64 decoding when parsing the token? Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
The HS512 algorithm supposedly just uses the string you pass. So if your JWT exchange only works if you base64 encode the signing key on Java side, maybe think about how that key got into PHP, and maybe use base64decode before you pass the key into the signing. You could also use To rephrase it: The key has no formal format to follow for this algorithm besides being of a minimum length it bits, so it does not matter if a string of a certain length does not contain any nonprintable characters because that was the random output, or because it is the result of base64-encoding binary output. Base64encoded strings are longer in character count, so the process would not fail because of a too short key string. It will not fail because of invalid inner format (RSA for example uses the openssl extension and requires a certain text format for the key string). So it seems to just fail validating the signature, but in reality it is simply using a different key. |
Beta Was this translation helpful? Give feedback.
The HS512 algorithm supposedly just uses the string you pass. So if your JWT exchange only works if you base64 encode the signing key on Java side, maybe think about how that key got into PHP, and maybe use base64decode before you pass the key into the signing. You could also use
base64Encoded()
instead ofplainText()
to base64-decode the key right away.To rephrase it: The key has no formal format to follow for this algorithm besides being of a minimum length it bits, so it does not matter if a string of a certain length does not contain any nonprintable characters because that was the random output, or because it is the result of base64-encoding binary output. Base64encoded strings are …