

Static constexpr const char* buffer_token = "2nN-d0Cn5dgb3K9JMI41nrEaK_AVSMRG9c5cyZqXpnMQETfGcDEs0jPzmRh-jDc-Kuq53naOtjkItMcR_vYPn72dKZ4Fpp8mvOAZXypkVCLzof3Lsxrtqq9G3V4LNTuOHiXW_q-9mEu51zWg1HDr1-rSt3YXkFFSWp5e4MWS2TNP1MB7lBbZC-kdMZ_GqZ9lrfNo2YqJR7tqcHOrfOmFTzqxVivEB8s-A0iEv_MwdlS6LpJBKU9-d94i1P9Lsqzlg7b_0ekRoYJEG4DXeNp2zxxBxZ1u3FBlIbyJoOGDmX-EU4A5eh2RlDdEvG1YF_zcMARpP1bFV86WTSOuQ"

I printed the signature after the b64 decoding in hex on the gdb and after the urlsafe_b64decode on the python and the values were the same (except some symbols at the end in the python version) which even more made be believe that the replacing strategy should be working.

The same token and key are validated using python and online JWT validation so they should be ok. I tried first to use RSA_verify, but the error is the same. Is there some rule for base64 url decoding that I am missing or is the approach with first replacing the symbols wrong in any way? To be able to get the proper signature length I also had to manually add the padding ('='). I only do not have the base64 url decode function, so I manually executed the steps as I understood it - before calling my base64 decode function I replaced '-' -> '+' and '_' -> '/'. I am quite new to openssl interface and base64 decoding rules as general and trying to verify JWT signed with private key (RS256 alg) using the solution: Segmentation Fault while verifying JWT token using a public key through openSSL in C++ But my sample JWT is failing to verify.
