Closed dextermb closed 6 years ago
@dextermb I'm not sure why you closed the issue, but the same thing happening to me. RSA256 keys doesn't seem to be decoded properly. If you managed to solve the issue, can you please share why it happens and how to solve it?
There was a dumb mistake elsewhere in the code that I had missed. RSA256 now works as expected for me.
@dextermb can you share your dumb mistake in case it's the same one @OrRosenblatt is experiencing?
I implemented this into Laravel, used $request->header('authorization')
but I did not strip Bearer
from the token, meaning it was decoding with Bearer <token>
.
Completely separate file, didn't think to check it 😢
Thank you @dextermb! Apparently it was exactly the same issue, and stripping the Bearer
part from the header fixed it 😄
@dextermb Just FYI, Laravel has a helper method for getting the bearer token
$request->bearerToken();
Thank you I guess this thread is old, but that dumb mistake from @dextermb saved my day
@dextermb can you share your dumb mistake in case it's the same one @OrRosenblatt is experiencing? Thank you for asking @dextermb on the dumb mistake, 'cause that dumb mistake saved my day.
Hello @dextermb . I can't figure how you solved this problem. I am using core php and not laravel. Any more explanation will be of great help. Thank you
Hey,
I am attempting to encode and then decode a JWT token using an
RSA256
key pair. But no matter what I try I am always getting theDomainException
:Unexpected control character found
.I have attempted different methods of generating and fetching keys using PHP's OpenSSL library, but nothing seemed to work. So here's some of the code I am using.
Class constants
generateKeys
method internals:loadKeys
method internals:Encoding:
Decoding:
My suspicion is that encoding using
RSA256
does not seem to be working properly. Can anyone confirm or deny this?Notes:
file_get_contents
inopenssl_pkey_get_private
andopenssl_pkey_get_public
respectively.