Search code examples
javaencryptionjwtjose4jjwe

Error Decrypting JWE


Kind of new to the JWE Decryption thing. I have a server that performs the JWE and sent it to client based on a key that is shared between server and client.

I am using a Jose4j for decrypting and am getting this error

java.lang.NullPointerException: The plaintext payload for the JWE has not been set.

I am using the sample code as shown in this link,Receiver part

https://bitbucket.org/b_c/jose4j/wiki/JWE%20Examples

I don't have any insight into the server am just writing the client. I am confused if the paylaod itself is not coming or that framework is goofing up trying to decrypt.

Any pointers to debug the issue is appreciated

Regards, Aravind


Solution

  • That particular exception is only thrown from the getCompactSerialization() method when there is no payload set - getCompactSerialization() is the last step on sending/encrypting side to create the JWE. If you are decrypting, you shouldn't be calling that. Maybe you've got an accidental call somewhere? Otherwise, the code your using as well as an example raw JWE value might help troubleshot (and keys, if it's just a test and you can share them).