Skip to content

Intermittent “Invalid Padding” Error on openssl_verify() in Symfony/PHP with Identical Data #61217

Closed Answered by Ordwen
Ordwen asked this question in Q&A
Discussion options

You must be logged in to vote

I finally found the solution to my problem, and I'm sharing it here in case it can help anyone else.

In my code, I isolated the signature this way:

$sign = $request->get(“sign”);
$decodedSign = urldecode(base64_decode($sign));

I was foolishly following the Paybox documentation, which said to first use urldecode and then base64_decode... It turns out that PHP already applies urldecode natively when retrieving the parameter, whether via $request->get(“sign”) or via $_GET[“sign”]. So, the following simple change solved the problem:

$decodedSign = base64_decode($sign);

Why this didn't happen on all strings, yet replacing a 6 with a 7 generated it, I have no idea. I suppose it's related to sp…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ordwen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant